Mike S
Mike S

Reputation: 4122

iPad application out of memory after only 5MB

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.

Upvotes: 1

Views: 2221

Answers (1)

Brad Larson
Brad Larson

Reputation: 170317

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.

Upvotes: 1

Related Questions