iOS - Memory Management

Storage control in iOS was originally non-ARC (Automatic Referrals Counting), where we have to maintain and launch the things. Now, it facilitates ARC and we don't have to maintain and launch the things. Xcode manages the job instantly in gather time.

Memory Management Issues

As per The apple company certification, the two significant problems in memory control are −

  • Freeing or overwriting information that is still in use. It causes memory crime and generally outcomes in your program failing, or more intense, damaged customer information.


  • Not liberating information that is no more in use causes memory leaking. When assigned memory is not released even though it is never going to be used again, it is known as memory flow. Leaks cause your program to use ever-increasing quantities of memory, which often may outcome in inadequate program efficiency or (in iOS) your program being ended.

Memory Management Rules


  • We own the things we make, and we have to consequently launch them when they are not required.


  • Use Retain to obtain possession of an item that you did not make. You have to launch these things too when they are not required.


  • Don't launch the things that you don't own.

Handling Memory in ARC


  • You don't need to use launch and maintain in ARC. So, all the perspective controller's things will be launched when the perspective operator is eliminated. In the same way, any object’s sub-objects will be launched when they are launched. Observe that if other sessions have a powerful mention of an item of a category, then the whole category won't be launched. So, it is suggested to use inadequate qualities for associates.

Memory Management Tools

We can evaluate the use of memory with the help of Xcode device equipment. It contains resources such as Action Observe, Proportion, Leaks, Zombies, and so on.

Steps for Analyzing Memory Allocations

Step 1. Start an current program.

Step 2. Choose Item and then User profile as proven below.


Step 3. Select Allocations in the next screen shown below and select Profile.

Step 4. We will see the allowance of storage for different things as proven below.

Step 5. You can change between perspective remotes and examine whether the storage is launched effectively.


Step 6. In the same way, instead of Proportion, we can use Action Observe to see the overall storage assigned for the program.


Step 7. These tools help us access our memory consumption and locate the places where possible leaks have occurred.