#1 By: indy2005, January 25th, 2012 01:24
I am not much of an expert in using Instruments, but my game which uses CCMask amongst other things to simulate bullet holes in sprites, starts off all well and good at 60 FPS, but gradually degrades to about 30 FPS.
I found a few memory leaks, and bad retains and got rid of them. Instruments now shows more or less a constant 15.4 Mb of active memory use, and the number of live objects seems to be steady around 21,000...i.e I think I have got rid of most of the memory leak issues. Unless the Sprite property of the Render Texture is somehow being retained, but I would imagine seeing total memory increase above 15.5 Mb over time.
And 1522 Immutable Strings in memory...whats that all about!?
Its a release build.
An advice appreciated, as once I sorted my leaks out...I thought things would improve.
Its only a whack a mole...actions throw things in the air, you tap them, and a mask cuts a hole in the sprite texture...few particles, but nothing is retained now beyond adding as a child to the parent node.
#2 By: indy2005, January 26th, 2012 08:21
now i have moved to using Object Pools this seems to be working better, but I don't know why allocating a few sprites on the fly would slowly the game down...I was releasing them all, and only allocating a few sprites every few seconds? I would have through an iPhone 4 could handle creating the occasional object!
#3 By: blackmouth, January 26th, 2012 08:37
I've lately started using the allocations instrument and pressing the mark heap button at intervals you would think the problem happens. Say you start a new scene, click the mark heap button, then repeat the process. The chunks of stuff allocated should eventually go back down to zero, if it doesn't then you can go back and look at what's still hanging around.
Also, you can check to see if that sprite is released by printing something in the dealloc method.
#4 By: indy2005, January 26th, 2012 18:54
Thanks...have been sing both techniques, slthough I am never sure what t subsequent heap snapshots show...is it just the new objects created since the last heap snapshot?
#5 By: indy2005, January 26th, 2012 22:05
this seems to look reasonable....
#6 By: blackmouth, January 26th, 2012 22:54
Yea that looks fine. I would use time profiler now and see what's taking up so much processing time.
#7 By: indy2005, January 26th, 2012 23:20
still not quite sure how to interpret the heaps, and what the types are.
When you baseline, and then you subsequently take a heap snapshot, do you only see the objects allocated from that heap snapshot onwards...i.e. the 461 I can see in Heapshot 2....they must still be in memory...but don't form part of snaphot 3? Snapshot 3 had some living objects which thankfully reduced to zero....
Time profiler...will have a look, thanks for the help..Instruments is actually pretty darn cool.
#8 By: blackmouth, January 27th, 2012 00:13
Yes you want to create a baseline, say something like a scene replacement, then take heapshots when you reach that point again and verify the previous heap reduces to zero.