views:

137

answers:

1

I've looked carefully at leaks and I have none (very few - all under 400 bytes). I've read a few posts about not using imageNamed calls as they cache the images. I'm not using any of those. I'm using imageWithContentsOfFile.

I AM using lots and lots of images. Mostly rendered myself using graphics contexts. I'm releasing everything and you can see the memory being retained and then released in the instruments view.

Bottom line, after flicking back and forth through my images and tabs I get a memory warning level 1, then 2, then crash. All with memory usage usually under 5MB.

Is there some weird cacheing going on? This is driving me nuts. My iPad application is unusable as it crashes within a few minutes of using it as it seems to gradually piles up in memory without indicating any leaks or large memory usage.

Is it something to do with my 'Live Bytes' being 4.57MB but my "# Living" being 53825? Why is there so many objects still living? Is a living object count of > 50,000 normal? It keeps going up and up (the object count) even though the 'Live Bytes' stays the same.

A: 

As I describe here, the Allocations instrument does not show the total memory usage of your application. The 5 MB you are seeing in that instrument is only the tip of the iceberg.

Instead, you'll need to use the Memory Monitor instrument to see your application's overall memory size. I think you'll be surprised at the numbers there.

Tuning memory usage is a complex task, particularly with the large images you are dealing with. Just because Leaks doesn't show anything leaking does not mean that you aren't accumulating memory in some area. Perform repetitive actions in your application and use the new Heap Shot functionality in the Allocations instrument to see which objects, if any, are accumulating between each time you repeat an action. I've caught many subtle memory buildups this way.

Brad Larson
I'd wager that it is mapped memory; use the VM instrument and see what is consuming pages.
bbum
Ok nevermind that. I was using Memory Monitor through the simulator. I am now using it against my iPad. Initial memory footprint is 25MB. At around 80-90MB after using it for a while I get my first memory warning. Its all downhill from there with eventually it crashing from no memory. Whats the use of marking heaps with the Allocations instrument if it only shows 2.5MB?
Mike Simmons
@Mike - While the absolute memory numbers may be off, what marking heaps gets you is an indication of which specific objects are accumulating from one step to the next in your application. There's a lot of information in the normal listing of all allocations, so the heap shot lets you refine that to focus in on specific time periods during your application's execution. Memory Monitor and the VM instrument (pointed out by Mr. Bumgarner) provide additional perspectives on what's happening.
Brad Larson
My problem is my retain counts were too high on all these views (cross referencing) so once I put debug pointers in their dealloc methods I could finally release them in the right ways and get them to actually call their 'dealloc' method.
Mike Simmons