Magical RAM clean after 5 minutes - why?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hi,

    I try to optimize my game (Dungeons of the Fallen on steam greenlight) since after I created a bigger map I've been experiencing RAM issues on runtime. When I get to the main gameplay screen the usage is above 1600MB with around 500 objects. When I disabled backgrounds the RAM starts with 1400 MB which is still a lot for a 2d game.

    Here's the fun part. After 5 minutes even without disabling anything and with 500 objects on frame the RAM usage magically decreases to 80MB. I don't see anything in my code starting with 5 minute mark which would affect it. Is there some internal cleanup of memory every 5 minutes?

    I have a quite lot of arrays loading at the beginning of frame maybe its somehow related to how they work..

    I will appreciate any help! :)


    EDIT: During another test on different map the cleanup occurred after around 2 and half minutes. On another one after 20 secs. I have no idea what triggers it though.

    EDIT2: It seems not to be map dependent. On the same map the cleanup can occur after 20 seconds, after two or after five. It appears to be random..

    Edited 5 times, last by hamstermp (September 10, 2017 at 12:02 PM).

  • Ok, it turned out that what takes so much place are the big backgrounds. However even if I uncheck Create at Start they got loaded into memory which surprised me. Only after deleting them the frame starts with ~200mb RAM instead of ~1400mb.

    So either I can do something about background sizes or somehow trigger this magical memory cleanup.

  • Firstly, people worry far too much about things using a lot of memory - that's what it's for. Unused RAM is wasted RAM, and as long as you don't run out of it altogether, it's not going to be the bottleneck that limits performance - even on their smartphones, who has less than 2GB of RAM these days?

    The reason for the initial high memory usage is that your app will be decompressing the image data, probably doing something with the collision mask, etc. At some point after it has finished doing that, the garbage collection kicks in to free up the memory that it was using (exactly when it will choose to do this is a very complicated matter, and it is both totally unpredictable and totally out of your hands - google "garbage collection" if you want to see what I mean).

    You'll find that "picture" objects use far less memory than "backdrop" objects.

    What big backgrounds are you talking about anyway? Your game appears to be tile-based? (please tell me you're not building a map from tiles and then saving it as a single image)

  • Hi,

    piscesdreams: no, I found out about it yesterday :)

    MuddyMole thanks for explaining the theory about the garbage collection it's all clear now.

    The biggest map I've done is 4160/3680. However, I think the issue here is the size of the Active objects with all the maps in the animation frames. I have 3 Active Objects on different layers with different maps based on the imported pngs made in Tiled.

    When the gameplay frame loads, the game checks from the save on which level you currently are and pick a map from animation frames of the objects.
    Two of them are pasted into the background (collision and non-collision) and the third one goes a layer above representing all things which are above the player in a top down environment (roofs, higher parts of trees).

    Until now I didn't have any performance issues with this approach so thought it was fine. What better way do you recommend when developing a top down action rpg like this Please login to see this link. I will keep experimenting. When the game is finished I can always use multiple frames and split the active object with backgrounds so each frame loads only few of them.

    Thanks for all the help.

    EDIT: Just realized I posted in wrong sub-forum. I use Clickteam Fusion 2.5.

    Edited once, last by hamstermp (September 11, 2017 at 4:39 PM).

  • The problem was that I stored all the maps as frames in a one active object. Even though only one frame map is needed when loading a level it seems like all the frames have been loading into memory. I made a separate active object for each map with Load on Call activated to make sure only the one in use is loaded into memory. Works like a charm. New levels load in a second :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!