views:

102

answers:

3

I have noticed in my application that didReceiveMemoryWarning gets called much faster if my phone has not been powered down for a long time. It almost seems like the pool of memory that my application can access shrinks with time.

Has anyone else noticed this and is there an explanation for it? Is there a course of action that I can take to keep this from happening?

I notice this happening when I use a good chunk of memory taking and manipulating a picture. Powering down and rebooting the phone helps out. Is it possible that the memory that my application can access is shrinking or maybe the existing memory is fragmented and rebooting defrags the existing memory?

Any explanation or help with this issue would be great. Thanks.

+1  A: 

Yes, this is, unfortunately, well known behavior. As the OS runs, cruft develops, and a restart is eventually required to clear things out. This is why many apps in the appstore request a restart before playing their game.

Ben Gottlieb
+1  A: 

Older versions of the iPod daemon, mediaserverd, used to leak.

That resulted in the behaviour you describe.

If one system service can leak, so can others.

Rhythmic Fistman
A: 

Just because we don't get to multitask our apps doesn't mean the iPhone is doing multitasking.

Open web pages in Safari stay in memory until the OS sends Safari the same memory warning you're getting. Mail might start working while your app is running and require more memory. the iPod app is also keeping quite a bit of memory for itself.

If you look at the console of the iPhone using the Organizer while your app getting a low memory warning you'll probably see some of the built in apps also getting memory warning and terminating things to free memory. It's quite interesting.

Ron Srebro