Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Development: How can I induce low memory warnings on device?

Tags:

ios

iphone

ipad

I'd like to test my app functions well in low memory conditions, but it's difficult to test. How can I induce low memory warnings that trigger the didReceiveMemoryWarning method in my views when the app is running on the device, not the simulator? Or what are some ways I can test my app under these possible conditions?

The reason I can't use the simulator is my app uses Game Center and invites don't work on the simulator.

like image 806
BeachRunnerFred Avatar asked Jan 17 '11 19:01

BeachRunnerFred


People also ask

How to handle memory warning in iOS?

Remove references to any temporary objects that you no longer need. If active tasks might consume significant amounts of memory, pause dispatch queues or restrict the number of simultaneous operations that your app performs. Failure to reduce your app's memory usage may result in your app's termination.

Is low memory warning can be simulated through the simulator?

There are various ways to identify low memory warnings.To simulate the memory warning we need to enable the toggle when the app runs on the simulator. To enable the logger for memory warnings, please run the app onto the simulator and then go to Debug → Simulate Memory Warning.

What is memory warning?

onLowMemory() raises when the system global memory is low. If the global memory is okay but your process takes more than 24MB on old Android devices, it will crash and you'll never get a low memory warning.

How do I reduce memory usage on my IPAD?

Go to Settings > General and go through your apps that have the most data. If your streaming or other apps occupy a couple of gigs and you don't have anything downloaded on those services, uninstall the apps and reinstall them. This will clear out the cache.


1 Answers

You can call the private method:

[[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)]; 

Just remember to use it on debug only, or else your app will get rejected.

like image 113
Enzo Tran Avatar answered Sep 20 '22 17:09

Enzo Tran