Performance issues. Total RAM 150 Mb!!!

FanStudioUKFanStudioUK Member Posts: 459
edited November -1 in Working with GS (Mac)
Based on this thread, I followed MynameisAce solution to reduce loading times

The problem is that my project is using 125 images - 7.2 Mb but when I run the project in GS Viewer the total RAM is starting from 140 MB and goes to 150 MB (sometimes the viewer crashes)

Is this a bug or should I forget about this method of lowering loading times and build actors for each image?

Thank you

Comments

  • PoseMotionPoseMotion Member Posts: 51
    I'm not sure if this is your issue but read the following topic all the way through...
    http://gamesalad.com/forums/topic.php?id=26244
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Regardless of file size, images all use RAM the same way once imported.

    As a rough guide, each pixel in an image uses 3 bytes of RAM - one for each color.

    To see how much RAM an image will use, simply multiply the total pixels by 3.

    For example: 480 x 320 x 3 = 460800

    So a 480x320 image uses about 460Kb - regardless of the file size.

    Older devices will crash when the RAM usage reaches around 40MB. Newer devices have higher limits, but unless you are targeting the newer devices exclusively, it's a safe rule of thumb to stay under 40MB.

    GameSalad flushes the RAM when you change Scenes. So you basically can have up to 40MB worth of images and sounds in each Scene. Actors with complicated Rules add to this total too. Any image or sound that you spawn into the Scene adds to the overall total as well.

    You need to carefully architect each Scene so it does not go over this limit or risk crashing the device.

    The iPhone4 and 4th gen ipod Touches have higher limits and can handle retina display sized graphics, as do both generations of the iPad. However, even on those devices 140MB is dangerously high.
  • FanStudioUKFanStudioUK Member Posts: 459
    @flashpulse I have some images that are not optimized but the total size of memory is huge. never happened before!

    @firemaplegames thank you very much for the tips, I'm currently modifying some images to see what the changes are. It was very strange because with this memory used the frame rate was between 58-60.
    I was testing on an iPhone 4 and crashed at 150 Mb :D
  • PoseMotionPoseMotion Member Posts: 51
    firemaplegames said:
    Regardless of file size, images all use RAM the same way once imported.

    As a rough guide, each pixel in an image uses 3 bytes of RAM - one for each color.

    To see how much RAM an image will use, simply multiply the total pixels by 3.

    For example: 480 x 320 x 3 = 460800

    So a 480x320 image uses about 460Kb - regardless of the file size.

    Older devices will crash when the RAM usage reaches around 40MB. Newer devices have higher limits, but unless you are targeting the newer devices exclusively, it's a safe rule of thumb to stay under 40MB.

    GameSalad flushes the RAM when you change Scenes. So you basically can have up to 40MB worth of images and sounds in each Scene. Actors with complicated Rules add to this total too. Any image or sound that you spawn into the Scene adds to the overall total as well.

    You need to carefully architect each Scene so it does not go over this limit or risk crashing the device.

    The iPhone4 and 4th gen ipod Touches have higher limits and can handle retina display sized graphics, as do both generations of the iPad. However, even on those devices 140MB is dangerously high.

    But a graphics card doesn't see 480x320. It will see it as 512x512 because graphics cards use the power of 2. Graphics cards see square triangulated polys. And 480x320 isn't close to being square. So it pads it at run time and therefor you have wasted memory.

    This is why I'm trying to explain this. As I'm seeing a lot of people complain about large memory consumption or images that don't line up right. So I'm just trying to explain so people can create more efficient games. ;)
  • LuckyLurcherLuckyLurcher Member Posts: 343
    I don't get this. When I was using 8 bit & 16 bit computers, an 8x16 pixel image took up twice the memory of a 8x8 image. But it seems you are saying that now an 8x16 pixel image takes up a 16x16 memory size. I have an image in my current app which is 480x16 (960x32 for retina display) pixels- would this use 512x512 of ram?
  • PoseMotionPoseMotion Member Posts: 51
    LuckyLurcher said:
    I don't get this. When I was using 8 bit & 16 bit computers, an 8x16 pixel image took up twice the memory of a 8x8 image. But it seems your are saying that now an 8x16 pixel image takes up a 16x16 memory size. I have an image in my current app which is 480x16 (960x32 for retina display) pixels- would this use 512x512 of ram?

    Correct! The graphics card, due to what a processor calculates, only see squares. So it would see 512x512. Now in programming languages you can load a 512x512 image that has multiple art pieces in and CLIP it legally. Hope that helps.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    @flashpulse:

    The memory "containers" do not need to be square. That is an older limitation of graphics cards from the good old days. iOS can handle rectangles. But they are in powers of 2.

    A 1012x60 pixel graphic will fit into a 1024x64 memory location.

    But you are correct that a 480x320 will fit into a 512x512 memory container. And use that much more RAM.
  • LuckyLurcherLuckyLurcher Member Posts: 343
    Thats quite a relief! I was beginning to worry! TShirtBooth's video was correct all along!
  • PoseMotionPoseMotion Member Posts: 51
    LuckyLurcher said:
    Thats quite a relief! I was beginning to worry! TShirtBooth's video was correct all along!

    Do you have a link?
  • LuckyLurcherLuckyLurcher Member Posts: 343
    Can't find it right now, but I think there is a link in the other thread you were posting in earlier today.
  • FanStudioUKFanStudioUK Member Posts: 459
    I managed to resize the images and I reduced the Total memory from 150Mb to 70Mb on iPhone 4 and 30 Mb on 3GS.

    I had a problem with an animation which was consuming a lot!!!

    Thank you guys!
  • PoseMotionPoseMotion Member Posts: 51
    FanStudioUK said:
    I managed to resize the images and I reduced the Total memory from 150Mb to 70Mb on iPhone 4 and 30 Mb on 3GS.

    I had a problem with an animation which was consuming a lot!!!

    Thank you guys!

    Glad to hear!
  • outasiteoutasite Member Posts: 417
    Here is TSB's video on Optimizing art.

  • PoseMotionPoseMotion Member Posts: 51
    Ok, thanks for the link. But I don't believe a 300x300 image is a true power of 2. As it's only divisible by 2 twice. And 75 can not be divisible by 2. I think it's best to stick to 8, 16, 32, 64, 128 and so on.

    Also, being that GameSalad is a Intel app, Mac users are using the latest cards and a image of 32x128 is fine. As both numbers are power of 2. This isn't so true for Window users though. As some users may have older cards and they will not except anything but power of 2 square images. Which may or may not be a concern for HTML5 games. I haven't research enough on HTML5 yet myself.

    Anyway, I was just trying to help and I hope no one took my post as a fuss. ;)
  • StuartYStuartY Member Posts: 134
    I have the opposite problem - my graphics and sounds take up <5mb, but the "game engine" - rules, I guess - takes up 30mb, and the mysterious "other" category is eating up 13mb too. Unfortunately, I don't think there's a way to significantly cut down on the number of rules. This leaves me at up to 60mb.
Sign In or Register to comment.