Use "dump" layout improves memory use?

  • So I have this game.. lot of towers, monsters, effects, particles.... the memory use indicated by C2 is 80mb.

    All these objects are in my "main" Layout, I like to call GameMain, where my game occurs (other layout are my levelSelect, gameOver etc...). They are destroyed at the start of the layout, and created when needed.

    So I take all these objects, and I cut/paste them in a "dump" layout, never used, and I see the memory use dropping to 40mb.

    Will this method will have actual impact on the performance of my game, on mobiles especially? What does this drop of memory use actually means?

  • The memory usage is based on objects initially placed in the layout. If you delete them and create them at runtime, then the runtime memory usage hasn't actually changed, but C2 will estimate the memory usage being less based on the initially placed objects. Basically the memory estimate assumes you don't create any objects at runtime.

    It's also a bad idea to delete objects you actually use from the layout, because if they are initially placed, C2 will pre-load them when the layout starts. If they're not initially placed in the layout, it will be forced to load them at the moment you create them, which can jank the game.

    tl;dr it will make things slightly worse.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok I see your point.

    But this method could be good if you're based on your level design. I mean no need to have X unused sprites of monster in the level 1 of your game, when you use only 1 or 2.

    Just create them at the start of the game layout, the destroy them. Maybe it will jank the game for a very short time, but only at the start of layout...

    Having ALL the enemies monsters at level 1where only a couple are used is waste of memory right?

  • You should only have objects placed on the layout that the layout really does use. Don't place objects which are never used on that layout, since it will waste memory (C2 will preload them but they will never be used). Conversely, don't delete objects which really are used - the preloading system depends on using the initially placed objects. Even if you create them on Start of Layout, it is less efficient. If you change layouts and the previous layout used that object, if it's not initially placed on the next layout, C2 will unload it, and then reload it again in Start of Layout. This pointlessly unloads then reloads the textures for it. If it's initially placed, C2 knows to keep it in memory if the previous layout also used it.

    It's pretty simple really: just have the objects the layout uses initially placed on the layout, and everything is optimal.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)