You have to use both Instruments and good old fashion print statements.
While Instruments doesn’t give you a lot of info and it makes your app really slow while its checking and there is little to know information on using it, it does do a good job of pointing out when memory is growing. Vague locations like Audio Mixer or vsprintf only give you rough ideas (if its Audio Mixer, focus on your sound/music code), UIKit: probably not releasing objects, etc.)
Then for your own printing purposes. There are two blocks of memory that you need to measure: Lua memory and Texture Memory. While I don’t care for either of those terms, since it appears Texture memory is really used for any big blocks of allocated memory (audio, display objects etc. and not just “textures”. Lua memory is your variables, tables, strings, etc. I’m not sure which pool of memory display.newText comes from (I suspect Texture)
Lua memory can be found with one of two calls:
memory = gcinfo() or
memory = garbagecollect(“count”)
They are for a lack of better term, the same. I think there is a move to have us use gcinfo() instead. Both return the amount of non-texture memory in use and its measured in Kilobytes (1024 bytes).
Texture memory can be gotten like this:
texturemem = system.getInfo(“textureMemoryUsed”)
This value is returned in bytes and may be more useful scaled to MegaBytes which is likely how youu’re thinking about it. So:
texturemem = system.getInfo(“textureMemoryUsed”) / (1024 * 1024)
I found it helpful, in particular for games that have a beginning of a round, to measure there and see what’s different before you load up the new level.
When looking for leaks, you are looking for leaks that grow over time. For example, there is a leak in the Audio Mixer that happens at app start up, stands out big time in Instruments, but it only happens once. So don’t worry about tracking down that. But if your app is growing by a few megabytes every few minutes, you have to take care of that or your app won’t get approved or if it sneaks by Apple, then you’re going to get negative reviews when it starts crashing peoples phones.
Leaks in the kbyte range will probably get past Apple’s review process, but over time they will cause your app problems and they need to be taken care of.
Leaks in the 16 byte range, if you can find them, great, but I don’t spend a whole lot of time trying to hunt them down. It would take a very long time for a leak that small to be an issue. I shouldn’t say that. 16 byte leaks happening every 10 seconds is a problem. 16 byte leaks happening once a round or once every few minutes, not so much…
[import]uid: 19626 topic_id: 17011 reply_id: 64028[/import]