Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - i receive memory warnings but have no idea why

I am developing for the iOS and checking my app with IPhone and IPad.

I receive many memory warnings (didReceiveMemoryWarning is called) but have no idea why. My app is using ~35MB in the peak points, and 4-5 MB when it the lowest point.

I tried to find leaks using 'instruments' but could not find any critical issues.

Is there a good way to find out why the system sends memory warnings?

like image 227
Erik Sapir Avatar asked Jan 28 '12 15:01

Erik Sapir


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.

What is a memory warning?

The Memory Warning Threshold Exceeded or Memory Critical Threshold Exceeded alerts appear in Deep Security to alert you that a host's memory usage has exceeded a certain amount. A warning alert indicates that 70% of the host's memory is used, and a critical alert indicates that usage has exceeded 85%.

Why does my iPad say low memory?

A: There are several possible causes, but the most likely one is that your iPad is running out of storage space. To find out how much memory is available, go to Settings, click General and select "iPad storage." If you are close to one gigabyte remaining, you'll need to delete some data or apps.

What is iOS memory?

Memory refers to the hardware that is utilised to store data on the device. The iPhone has two options in terms of data storage: the disc and the Random Access Memory (RAM). However, when an app is run on an iPhone, a file containing all of the executable instructions is loaded into the RAM.


2 Answers

Memory warning is to be expected in an iOS app. It doesn't have to be because of your app. Other apps are still in memory even if the apps are suspended. The OS will do memory management by sending memory warning and kill apps when necessary. As long as you're using reasonable amount of memory (with little to no memory leak) and handle didReceiveMemoryWarning properly, you'll be fine.

Also, when your app is in suspended mode, if your app is using little memory footprint, your app will more likely to survive killing process. As app with larger memory footprint will be terminated first.

like image 170
X Slash Avatar answered Oct 21 '22 12:10

X Slash


I also found that "Product -> Analyze" (Shift+Command+B) can help you sort out some code issues before you start using Leaks. With the introduction of ARC this became less useful though.

like image 26
DJ van Wyk Avatar answered Oct 21 '22 11:10

DJ van Wyk