PDA

View Full Version : app receives Memory Warning




sujithkrishnan
Jul 18, 2008, 07:36 AM
Hi all..

In my app, the applicationReceivedMemoryWarning is getting called??

how to trace out the origin / who is responsible to call, which line in code ???

Plzzzzzz help.....



SwampThingTom
Jul 18, 2008, 09:07 AM
Hi all..

In my app, the applicationReceivedMemoryWarning is getting called??

how to trace out the origin / who is responsible to call, which line in code ???

Plzzzzzz help.....

The Instruments tool is a great way to track down memory leaks. The "Instruments User Guide" in the Dev Center describes how to use it. Very easy and *very* useful.

Tom

Enuratique
Jul 20, 2008, 11:20 AM
Hi all..

In my app, the applicationReceivedMemoryWarning is getting called??

how to trace out the origin / who is responsible to call, which line in code ???

Plzzzzzz help.....

It's called by the iPhone OS when it realizes it's about to run out of memory. There is no singular place to find out who's calling it. The intent of that method being called is to try and release any non-essential allocated memory to prevent a force-quit of your app. Chances are, however, you have a memory leak that needs plugging.

sujithkrishnan
Jul 22, 2008, 02:31 AM
It's called by the iPhone OS when it realizes it's about to run out of memory. There is no singular place to find out who's calling it. The intent of that method being called is to try and release any non-essential allocated memory to prevent a force-quit of your app. Chances are, however, you have a memory leak that needs plugging.

But my app is taking a max of 2.75MB (highest peak shown in INSTRUMENTS)...
I read that around 24MB is available as heap space...

Is the above method(AppRecievedMemoryWarning) get called at those lines, where alloc /copy occurs??

Enuratique
Jul 22, 2008, 06:29 PM
But my app is taking a max of 2.75MB (highest peak shown in INSTRUMENTS)...
I read that around 24MB is available as heap space...

Is the above method(AppRecievedMemoryWarning) get called at those lines, where alloc /copy occurs??

How long is your app running before it gets the memory warning? Does Instruments say you still have leaks? Is Instruments collecting data throughout the life of the program (I had a weird case where Instruments would stop collecting data after my app's initialization phase). Could you possibly take a screenshot of Instruments when the memory warning happens?

Also, the "peak" memory may be a misleading thing to look at. Take for example Instruments running my app.

http://i307.photobucket.com/albums/nn306/Enuratique/InstrumentsExplanation.png

Note how the peak is less than total memory consumed over the life of the application. It's possible you have a thread that Instruments isn't measuring so any leaks in that thread are going undetected and thus causing the low memory warning. If that overall bytes column is continuously growing (even after initialization has completed) and you're not doing anything in the application - then I think that's a telltale sign you have a leak somewhere. I'd be curious to know what the overall bytes value is when you receive the low memory warning.

receiptsondisk
Jan 17, 2009, 01:43 PM
add NSLog messages to your didReceiveMemoryWarning method

CommanderData
Jan 17, 2009, 02:50 PM
add NSLog messages to your didReceiveMemoryWarning method

You're a few months late to that party ;)