Question

I've heard that didReceiveMemoryWarning is most likely to be called when you are consistently leaking allocations. However, under ARC I have always thought that allocated local variables are dealloc'ed after we pass the block they are instantiated in. Would these leaks have to all be properties?

I'm trying to create the proper recovery for if didReceiveMemoryWarning is called in my application, but I've been unable to see it thus far. I'm looking for help on understanding when it would be called, and whether these leaks would have to be properties vs. local variables (under ARC)?

Was it helpful?

Solution

Just use the "Simulate memory warning" command in the Hardware menu of the Simulator.

If you want to do that by code you could use the following code (note that this is private, so you have to remove it for AppStore releases, it is just useful during debug)

[[UIApplication sharedApplication] _performMemoryWarning];

Both of this procedures replicate what happens when a device is in a low memory situation, so the didReceiveMemoryWarning methods will be fired.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top