Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Find the Source of Memory Pressure in an iOS Application

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????

like image 975
Musadhikh Muhammed K Avatar asked Nov 06 '13 15:11

Musadhikh Muhammed K


People also ask

How do I check my memory usage on iOS?

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.

How do I see memory management in Xcode?

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.

How do I view iOS device logs?

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.

How is memory managed in iOS?

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.


1 Answers

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.

like image 148
Ashok Avatar answered Oct 17 '22 08:10

Ashok