Artwork size => app crashes

LAdrianLAdrian Member Posts: 237
edited November -1 in Working with GS (Mac)
Hi Guys!

I'm working on my first game for the iPhone 3GS and I have a problem with the artwork size.

Until now I had 220 files taking 10Mb (all are power 2) and everything worked fine, the game loaded pretty fast in the iPhone viewer and the frame-rate was ok (35-47 fps). Yesterday I added to a very small scene a big explosion (80 frames taking 14Mb). The problem now is that when I try to test it in the iPhone viewer it crashes after loading the scene. Like I said, the big explosion is on an nearly empty scene with very little artwork so I thought that will be fine but apparently not.

My guess is that the app loads all the artwork for all the scenes even if you don't used it in that particular scene that it's loading. I hope I'm wrong since that would be a serious limitation (the images take only 23Mb, I'm sure that are more heavy app for the 3GS). Or maybe there is a way to specify what actors not to load for a scene?

Any idea how I could make it work? Really, 23Mb is way to little for my game.
Thanks a lot,
Adrian

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    The file size does not relate to the RAM usage. RAM usage is what will cause the iPhone to crash. An original iPhone will start to crash at about 40MBs of RAM usage.

    You always need to be conscious of you RAM usage, but it does not have to do with file size. For example, MYST is 700MB, but the RAM usage does not cause the iPhone to crash.

    I made a post the other day about image size in relation to RAM usage here:
    http://gamesalad.com/forums/topic.php?id=7249

    For the sake of argument, let's say your big explosion is full-screen on the iPhone (480x320). At that size, 80 images is 32MB. That will definitely cause the device to crash.

    You have very little RAM allocated to you on the iPhone. You have to allow room for the engine, as well as audio in your game.
  • LAdrianLAdrian Member Posts: 237
    Hi firemaplegames, thanks for the fast reply.

    I was also thinking that the file size shouldn't influence the ram usage.
    The explosion is indeed full screen (png 24 with transparency) and the 80 frames take 14 Mb. The way I setup the explosion is this: the actor has a timer that after 5 seconds plays the animation (80 frame). The thing is that the game doesn't crash when the animation is played, it crashes before the level is loaded even. So I see the progress bar loading the level, after is finished the black screen with the rotating loading icon appears and then crash (exits the app) and game salad shows device disconnected.
  • LAdrianLAdrian Member Posts: 237
    I made a little test with 3 scenes to see the difference on RAM usage:

    A. Almost empty, only the character:

    fps: 60
    images: 47.5 MB
    sounds: 11 KB
    game engine: 6.0 MB
    other: 20.7 MB
    total: 74.2 MB

    B: very little artwork

    fps: 60
    images: 50.1 MB
    sounds: 11 KB
    game engine: 8.4 MB
    other: 21.9 MB
    total: 80.4 MB

    C: almost full level

    fps: 40
    images: 52.8 MB
    sounds: 11 KB
    game engine: 8.4 MB
    other: 23 MB
    total: 84.3 MB

    I was expected a much bigger difference regarding the ram usage of the artwork (images). Only 5 MB between the empty level and the full level is very low, also there is almost no loading time between levels so I suppose that all are loaded in RAM at the beginning and that's something that I don't want. There must be a way to set a scene to load when accessed and then offload it from RAM when you go to the next one.

    Any suggestions?
    Thanks
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Yes, you cannot use that much artwork. It really needs to be optimized.

    In the images section of the RAM usage, the smallest # you have is 47.5MB.

    After you add up the Sounds, Game Engine, and Other, it seems that you are about 30MB already.

    So you really only have about 10MB or so to play with, not 50MB...

    Now, if this game is solely for the iPad, then you have a little more to play with.
    But over 40MB is starting to get into crashing territory on the iPhone...

    It is my experience that RAM does get flushed when you change Scenes.
  • LAdrianLAdrian Member Posts: 237
    That's my problem, 47MB RAM of Images for the empty scene that has only the main character that right now is the blue dude from the platformer example (with only two animations, running left - running right).
    Definitely looks like the RAM is not flushed between scenes :( Does flushing works when using the iPhone Viewer or should I compile the app?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    I do see it flushed in my game with the iPhone Viewer...

    You might want to try starting a new clean project. Slowly add in things one by one from the old project and test each new thing you add. That way you see what specifically causes RAM spikes.

    Plus, it's possible that the old project has become corrupted and is still retaining those images even though it would seem that you have deleted them.
  • LAdrianLAdrian Member Posts: 237
    Cheers firemaplegames,
    I made a new test project with 3 simple scenes and the ram flushing works ;) Thats the good news, the bad one is that I need to redo a lot of work :) but at least I have hope again.

    Thanks again for the suggestions ;)
Sign In or Register to comment.