I was debugging an app on a device. It worked perfectly for some time and then stopped with the error message "App terminated due to memory pressure". There is no error or crash logs.
Why did this happen? How can i resolve this? My app uses 10 to 30 mb ram while running. Is that a lot?
UPDATE: after using instruments i got this.. can anybody explain memory allocation????
UPDATE: i tried instruments and found leaks. i got some thing like this
i cant understand what does it mean and how to solve this????
Go to Settings > General > [Device] Storage. You might see a list of recommendations for optimizing your device's storage, followed by a list of installed apps and the amount of storage each one uses. Tap an app's name for more information about its storage. Cached data and temporary data might not be counted as usage.
Inspect the debug memory graph You can generate a memory graph of the objects and allocations in your app by clicking the Debug Memory Graph button in Xcode's debug area at the bottom of the workspace window. The memory graph shows the memory regions your app is using and the size of each region.
Connect your iOS to your computer with a USB or Lightning cable. Go to Window > Devices and select your device from the list. Click the "up" triangle at the bottom left of the right hand panel. All logs from all apps on the device will be displayed here.
Memory management in iOS was initially non-ARC (Automatic Reference Counting), where we have to retain and release the objects. Now, it supports ARC and we don't have to retain and release the objects. Xcode takes care of the job automatically in compile time.
I think 10 to 30 mb of app's memory usage is not an issue especially for latest model iOS devices (like iPhone 4 and 5), unless you have lot of other memory intensive apps running in background. They have 512mb to 1 GB RAM.
Diagnosis of issue -
To begin with, use memory graph in XCode 5. You may find this link useful.
Also, you may like to put breakpoints in didReceiveMemoryWarning
method provided by UIViewController.
And, to further dig down, switch to profile your app. (Xcode menu Product > Profile and choose Allocations in the dialog). Here, you will find a good tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With