Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What level of memory usage will trigger iOS's memory warning?

Tags:

memory

ios

swift

My app may consume tens of MB of memory, and in rare cases it reaches 100MB. Do I need to worry about memory warnings and implement didReceiveMemoryWarning()? And how much time do I have to release memory? (I need to persist the data in memory to the hard drive.)

Suppose I target devices after iPhone 5.

like image 651
NeoWang Avatar asked Oct 25 '17 03:10

NeoWang


1 Answers

First off, here's the discussion of the method didReceiveMemoryWarning from Apple docs.

DISUCSSION

Your app never calls this method directly. Instead, this method is called when the system determines that the amount of available memory is low. You can override this method to release any additional memory used by your view controller. If you do, your implementation of this method must call the super implementation at some point.

As per this reddit thread, even if you handle this event, your application can still be terminated to give space to the running applications. Also, often times all of the apps' didReceiveMemoryWarning on the device are invoked, not only yours.

I hope this answer is okay since this seems just a comment quoting the documentation :)

like image 65
Glenn Posadas Avatar answered Sep 29 '22 14:09

Glenn Posadas