First of all thanks for all of the work that community has posted on optimization and memory tracking/FPS viewing. These tools are amazing. I’m also about to try the 3rd party profiling tool.
I’m developing for the iPad right now (1 and 2).
I’ve been working on optimizing our game which contains a lot of PNG graphics to build the scene. I’m looking at a 3 to 4 layers making up the foreground and background of the scene. It has parallax scrolling, etc…
Some of the images are 1024xN where N is any variable height. I have a set of palm trees that are repeated twice so I can scroll to the right. For example I have one set of palms on the left hand side (1024x220) and another on the right and side (another 1024x220). These are as small as I can make them in Photoshop. But many layers are similar to this. I realize having such larger images can be problematic.
As you can imagine I was getting Memory warnings and the iPad 1 (I heard from a friend as I don’t have one) it would crash right after it loaded the first level. On the iPad 2 it ran great! with it’s dual core and 512mb of memory. However, I did notice at times it was throwing memory warnings level 1 and level 2. It never crashed.
This led me down a path of fixing my bad programming mistakes and freeing resources. I used the FPS and texture memory watcher to get a grasp on what was going on. I was running at 60fps on the device and my memory usage was 106mb. I changed the codes calculation to be:
(system.getInfo("textureMemoryUsed")/1000000)
to:
((system.getInfo("textureMemoryUsed")/1024)/1024)
I DO REALIZE that the previous version was an optimization step. That mine is really pretty much the same but I wanted to make sure I was reporting more accurately. Maybe I’m not thinking right about this. ALSO, I DO REALIZE this is slower! I get that… I don’t care about speed I care about tex memory usage.
So I went back and made sure I was freeing all my previous scenes after they user left them. I requested to collectgarbage("collect") in the hopes that GC would run, etc.
I also went though and freed all my sprite sheets after the sprites were created.
The result was the memory warnings went away for the most part. If I launched a bunch of different apps and then ran my app I could see each of them getting memory warnings and closing in the background. I would also tend to get at least one memory warning BUT no level. So instead of a memory warning level = 1 or 2 I simply get Memory Warning.
This is GREAT but the problem now is when I run the app my Texture Memory Usage is now: 148.xxx mbs. This is a pretty large jump from 106.xx mb. Could this be the GC not running with a stockpile of memory waiting to be cleaned up? Remember, I no longer have memory issues on the iPad 2 and I have no performance issues in the game. The frame rate stays high, the animation stays consistent, etc.
I am curious as to how well the iPad 1 will handle this. I keep reading info on how the texture memory max is 20mb. This sounds crazy and must be for something like Android right? or a Phone not a tablet? Is this true for iPad 1?
And honestly can anyone answer what the danger levels are for each of the platforms?
i.e.:
iPad 2 runs fine at 148mb texture memory on the device
iPad 1 ???
iPhone 4 ??
iPhone 3gs ??
Android Phones ??
Android Tablets ??
TIP: If you plug in your device to a Mac and go into Xcode-Window-Organizer you can see your devices applications and more importantly “console.” Run your app and you can see all your prints, memory warnings, and exactly what is happening on the device.
Thanks for any and all help,
-David
[import]uid: 27681 topic_id: 19079 reply_id: 319079[/import]
[import]uid: 24111 topic_id: 19079 reply_id: 73581[/import]
Thanks for sharing.