How to profile memory usage and performance with tools?

Of all the Trace Tools templates, I love to use:

  • Zombies to discover where an object is re-emitted is great for debugging EXEC_BAD_ACCESS .
  • Leaks for detecting memory leaks.
  • Core Animation w Color Blended Layers for determining frame rates and translucent subzones, great for smoothing UITableView scrolling.

I always hear people say to profile the use and performance of the applicationโ€™s memory.

  • Why should I profile memory usage and performance? My application is working fine.
  • How should I do it?

I used Allocations and I see that my iPhone application starts with a total allocated memory of 1 MB and grows to 5 MB after normal use. What is too much memory usage on the iPhone? IPad? Mac?

+47
performance profiling xcode allocation instruments
Jul 10 2018-11-11T00:
source share
3 answers

To answer the question, the use of profiling memory is especially important for iOS applications, since the iPhone and iPad have much less RAM than the Mac. The iPhone 4 has 512 MB of RAM, but earlier versions had 256 or 128 MB. The factor in RAM used by the OS and multitasking, and your application does not have a lot of RAM, so it is important to know how much memory your application uses.

Profiling performance is what you usually do when your application is slow. Profile it to find slow points in your code so you can run code faster. If your application works fine, you donโ€™t have to work through performance very often.

To answer how, use the Allocations tool to measure memory usage. The Live Bytes column in the All Distributions category indicates the amount of memory that your application uses. The Allocations analytic analysis tool measures memory growth in your application. Use the menu on the left side of the transition bar to perform heap analysis.

The Time Profiler tool profiles your application for performance. The hard part of using the Time Profiler tool is interpreting the results. The Time Profiler tool is not going to tell you that your application spends 75% of its time in function X. You need to dig through the data to find slow points in your code.

As for acceptable memory usage, it depends on the devices you want to support, and on the application. An application like Xcode using 100 MB of RAM would be fine, but an application like TextEdit using 100 MB for a single page document would be a problem. 5 MB should not be a problem for an iOS application.

+72
Jul 11 '11 at 18:48
source share

To answer some comments in Mark's answer:

Highlighting databases do not include OpenGL texture memory, which is used by CALayer / UIViews. This is a source of disagreement with the memory monitor.

See the answer to this question here: Understanding memory usage on iPhone

+6
Jul 17 2018-12-12T00:
source share

The memory actually loaded into the physical memory of the device is located in Resident Memory in VM Tracker Instrument .

Allocation Instrument only marks the memory created using malloc/[NSObject alloc] and some frame buffer, for example, a bitmap with a decompressed image, is not included in Allocation Instrument , but it always takes up most of your memory.

Please see WWDC 2012 Session 242 iOS Application Performance: Memory for information from Apple.

+3
Aug 22 '13 at 1:54 on
source share



All Articles