Reducing memory use ?

0 favourites
  • 9 posts
From the Asset Store
Memory game, with 10 levels for you to have fun. Made in Construct3, template available for purchase.
  • Hi all,

    I'm working on the Spooky Heroes project :

    scirra.com/forum/topic78999.html

    I didn't pay too much attention to memory use since the game is aimed at PC and images are not that big.

    However, I reached a point where the game does not work anymore because of this and I can't figure out how to correct it. I posted in the bugs section and Ashley pointed out the problem came from the memory use :

    scirra.com/forum/topic82826.html

    I searched for a solution but I'm lacking knowledge as to how C2 actually works with images and sprites.

    Let me explain :

    I wish to offer many kind of heroes as well as many kind of bosses to fight against. And the game is animated which means a lot of frames and sprites. I created all animations with Flash and exported them to PNG.

    When I check the folder size for the boss number 2 for example, all frames and animations included to this character, Windows indicate me a size of ~8Mo.

    When I import them in C2 and place the instance on a loader layout, the memory usage indicates 130Mo used !

    So I read articles and about the need for sprites to be a power of 2 (128x128) but even so, it seems a ridiculous amount of change between the 2 values !

    The boss 2 is ~200x520 in size which means if it becomes power of 2, it will use 1024x1024 in memory ? Is that correct ? Does it change the size for the whole animation ? the whole sprite ? if one frame change to 1100x1100 for any reasons, will it make 2048x2048 for the whole sprite or only this frame ? Or this power 2 rule only concerns tiled backgrounds ?

    When the games loads on launch, it can't loads everything because of t0o much memory use and display black squares instead of the actual sprites.

    For the moment a normal character on windows indicates a 2Mo size but in C2, it indicates 15Mo. I have 13 normal characters...

    Right now, the memory used on the preload page is 550Mo in total (with backgrounds and all)... Even if I optimize all of them, I will still need more of them and the size will still be a lot. I fear that I won't be able to implement everything I want for this game because the memory use on first laod will be too high.

    Could you give me more information about all this stuff because I'm guessing I'm mixing up things and it's quite confusing.

    How to make this work ?

    Thanks !

  • There is a difference between a saved image and a rendered image. Saved images are compressed to take up the least amount of space possible.

    While being rendered the image is not compressed. so one 512x512 image will take up 512x512x4 = 1048576bytes of graphic memory.

  • What is the x4 factor for ?

    Also, even if I reduce my images, it seems like if a game has a lot of different sprites, the memory usage will still reach a high amount, causing the same problem I have now...

    How do other platforms with big sprites usually do to reduce this problem ??

    Actually during the game the memory usage is under 70Mo, it's just during the loading that it fails to load images...

    Isn't there a way to prevent this problem ?? Because so far, it seems like my computer can't handle more than 400Mo memory usage during loading(displays black box instead of sprites). even if I reduce the sprite size... I'll still need many more character which will still reach this 400Mo limit...

    Does that mean there is no solution ?

  • I believe the 4 stands for R,G,B and Alpha.

    Some simple questions to help you along:

    Do you really need the sprites to be this big?

    Could you work with repetition instead of using new sprites?

    Can the animations be shortened without instantly looking bad?

    Even large game-making-companies use techniques like repetition to reduce the amount of graphic memory used by the game. It's just one of those things gamemakers should take into account.

  • This blogpost has information on wasting precious memory with graphics.

    And this topic has some nice info about reducing image impact on performance.

  • Ok I'm gonna check this.

    In worst case, I was thinking about creating separate parts for each characters (head, arm, body, leg, foot) and animating them directly in the code with the PIN behavior.

  • Another question I had about this was that only the total memory use is quite big. But actually, when the player play normally, the memory use is not that big.

    Isn't there a way to make the game load everything piece by piece ? For the moment, it seems like the game loads the whole images at once and since it becomes too big, some images are lost. Can't I make the game load it more slowly ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Construct 2 already manages memory efficiently: it only loads the current layout in to memory at a time (with the WebGL renderer, anyway). However if you have a single layout using tonnes of memory, it won't help you there. Construct 2's memory usage estimate in the status bar is based on the largest layout only, not the whole project.

  • Thanks for your answer Ashley &LittleStain. I've been able to diminish the memory usage thanks to that and I didn't start optimizing images yet. Also after reading the links given by LittleStain, it was already explained in those.

    So sorry to have bothered you about something already answered !

    Have a nice day/night !

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