AlexR AlexR - 1 year ago 65
Objective-C Question

Apple Instruments slows down app when analyzing memory allocations

When running my app in the simulator and analyzing its memory allocations using Instruments, the App runs very slow, it runs at less than 1/30 of its normal speed.

The app uses about 50 MB RAM and has approximately 900,000 life objects (according to Instruments).

Could this be the reason for the slow performance?

When running in the app on the device or in the simulator without using Instruments, it performs well (except the memory issue I am trying to debug).

  • Do you have any idea on how to solve this issue?

  • Did you encounter slow performance using the Memory Allocation

  • Would you consider having more than 900,000 life
    objects "concerning"?

enter image description here

Answer Source

Considering your Analyzer performance issue

In your specific case monitoring the app over a long period of time will not be necessary, as you reach the state of high memory consumption very soon. You could simply stop recording at this point. Then you won't have problems navigating through the different views and statistics to find the cause of the memory issue.

Analyzing the memory issue

Slowing down is normal. 1/30 sounds quite alarming.

You probably should track how the amount of life objects and the memory usage change while you use the app.

It is difficult to decide if a certain amount of life objects at a specific point in time is critical (though 900,000 seems very high).

In general: if life objects and memory usage grow continuously and don't shrink, that is a bad sign.

If you take a look Statistics -> Object Summary (Screenshot), Live Bytes should be a lot smaller than Overall Bytes and the amount of #Living objects should be a lot smaller than the amount of #Transitory objects.

enter image description here

The second thing you can look at, is the Call Tree view. It gives you a nice overview of which parts of the application are responsible for reserving large amount of memory:

enter image description here

Possible solutions

Once you detect the parts of your code that are responsible for reserving the large memory amount you can look for retain-cycles or you could try to use more autorelease pools in that spot.