Use "dump" layout improves memory use?

Discussion and feedback on Construct 2

Post » Fri Sep 01, 2017 5:33 am

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?
B
27
S
10
G
1
Posts: 23
Reputation: 2,239

Post » Fri Sep 01, 2017 10:42 am

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.
Scirra Founder
B
398
S
236
G
88
Posts: 24,441
Reputation: 194,681

Post » Fri Sep 01, 2017 1:01 pm

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?
B
27
S
10
G
1
Posts: 23
Reputation: 2,239

Post » Fri Sep 01, 2017 2:29 pm

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.
Scirra Founder
B
398
S
236
G
88
Posts: 24,441
Reputation: 194,681


Return to Construct 2 General

Who is online

Users browsing this forum: JesusJ and 7 guests