0 Favourites

Optimization question

  • Just doing final checks on my game. Right now in the debugger I got it down to 94mb memory usage. Great, since it was running around 230 before I started to optimize .

    Anyway, when I load the game up in Xcode (CJS exported) and run Instruments to test how much memory the game is actually using on my iPad mini it comes in around 203mb. I am using the Preload Sounds setting for my project, could this extra 100+ mb of memory be my sound files? All my sound files combined is 2.4mb, but I am not sure how they translate into memory usage. Audacity shows them at 44hz 16 bit stereo sound. If sound could make this big of a difference, I would consider down sampling them if need be.

    If it's not the sound, what could attribute to the increased 100mb of usage from the debugger to xcode?

    @Ashley, any input would be great.

    I reread the recent memory management post and I have a better understanding of sound. I have 48 individual sound files. Even assuming each one is 1 second long (though most are not), that would only equal about 8mb of memory. Unless my math is off, but 172kb per 1 second of stereo sound, times 48 = 8,256kb.

  • I believe it overhead from CJs but im not sure. its the same way on any mobile export option so ive assumed it was wrapper overhead

  • I can't imagine what would be 100mb of memory usage from the wrapper overhead. I have heard file sizes are bigger, as in download sizes, but not memory usage. Can you link me to any threads that talk about it? Thanks.

  • it might not be thats just what i assumed because i noticed on every mobile export ive done (android,Windows Phone,IOS) but not when i test in the browser

    also i just thought where are you looking at memory use in xcode because i now when the app loads is when it has its higher mem use then it goes down and and if your looking at the wrong place you might be looking at that peak usage and not what it is using?

  • Well, I think I am getting closer. I just went through the exported folder and I have 30+ sprite sheets in the 1024x1024 size. That's about 144mb right there (4mb x 30).

    Plus a 2048x2048 and several 512x512. All together, I am going to gather it equals about 200mb of memory usage. Now the question, is there a way to combine some of these? It seems like C2 create a sprite sheet for each object and puts as much on it as it can, but doesn't combine them.

    A good example is my store icons. Each is it's own object.

    I guess this is a consideration when creating the game from the beginning . Now my game is completely playable on all newer devices as I have tested it on, I'm just trying to learn how to optimize it more.

  • it might not be thats just what i assumed because i noticed on every mobile export ive done (android,Windows Phone,IOS) but not when i test in the browser

    also i just thought where are you looking at memory use in xcode because i now when the app loads is when it has its higher mem use then it goes down and and if your looking at the wrong place you might be looking at that peak usage and not what it is using?

    I'm using the built in instrument tools without Xcode. It gives me a constant rundown of how much memory my app is using on the device during the entire time I am playing the game. Since all assets are loaded in at the start, the number stays pretty constant. CJS does a good job of freeing up memory when it needs it or gets memory warnings, but this can sometimes cause little hiccups depending on the device.

  • Does the transparent space in each sheet not matter towards memory usage? I'm curious because I have several sheets that all the images would fit on a 256x256 sheet, but instead is using a 512x512.

    I'm sure it's just for some reason that I don't understand, and will once this thread is done .

    Here are a few where the images would fit on a smaller sheet.

    The frenzy one for example, each image is 256x64. All 4 should fit in a 256x256 sheet, right?

  • So I made a few changes, essentially getting rid of 4 of the 1024x1024 pngs and the memory usage when from 203 to 190. A step in the right direction for sure.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • the best way to solve that export image issue is in c2 instead on having something like 256x256 have 255x255 that one pixel is needed to line them up right. i believe the reason for that is c2 puts a 1px gap when making spritesheets

    ex for your 4 256x64 do 255x63 and it will fix it i had that same issue fixing this can improved memory alot i decreased mine by about 1/3

  • I tried that and it didn't work, maybe more than one pixel is needed? But yeah, seems like a good approach. Little by little .

  • IT should work if and any the images inside the spritesheet are smaller(or bigger)... say you have 3 255x63 and one 32x32 sometimes ive seen it mess up and you need to make it 31x31

    it might be 2 pixels i just looked at some of mine and it looks like i made them 124x124 and the only reason i can think i would make it that way is to make the sheet correct so it might be good to try

  • Afaik, spritesheeting adds one pixel all around the image, so I would think 2 pixels less at least.

    Also I though cocoonJS extracted all sounds on startup (maybe music too?) And dont release them during the gameplay, so that could also be a problem if your sounds are numerous and high quality.

  • CocoonJS does not support memory management. It will load the entire project in to memory on startup. This makes it use considerably more memory than the C2 estimate (which applies to platforms which support memory management - all of them except CocoonJS). Despite our best efforts to help them, Ludei never fixed this. It's one of the reasons we've deprecated support for CocoonJS. As a workaround, use any exporter other than CocoonJS and it will probably use much closer to the estimated memory in C2. We recommend Crosswalk for Android.

    BTW, yes, transparent pixels still take up memory! The entire image rectangle uses memory, transparent pixels is just another "color" as far as the image content is concerned.

  • Thanks Ashely, I do understand that CJS loads up everything at once. Which is fine, a majority of my project is the main game anyway, there isn't much that would take advantage of the layout by layout loading anyway. If I got as good of FPS in crosswalk as I did in CJS, I might consider switching.

    Thanks for the answers and I will work it from there. I'll keep trying crosswalk to see if it improves for me.

  • Also, I keep hearing about crosswalk, but that is not an option for IOS, correct?

    What is the go to solution for iOS right now that has memory management? Is it Ejecta?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
353 32,068
yojona's avatar
yojona
Unread sticky
192 1,337,378
Kyatric's avatar
Kyatric Construct Team Support
Unread hot topic
47 2,261
marceloborghi's avatar
marceloborghi