Wael Showair
Wael Showair

Reputation: 3102

iOS Instrumentation: how to interpret Memory Allocations Template?

I am using Allocations Profiling template for an iOS Instrumentation. I created an extension to UIView class, that takes a snapshot for a view that is not added to the view hierarchy. I want to double check how much memory does my new method consume. I have found out that my new method allocates 288 Bytes from the heap as indicated in the following image. enter image description here

Then I navigated to the corresponding method and I found out that there is a big memory amount as expected. Have a look on the following image. enter image description here

My questions are:

  1. Why could not I see these huge number in the heap?
  2. Where is this huge memory allocated from?
  3. Is there a specific detail view (other than Call Tree) that reflects this hug number?

Please note that I am not asking about what is the best way to take a snapshot for a view. I am already familiar with Apple method snapshotView. I am doing this exercise just to test my understanding for the Memory Usage in iOS.

Upvotes: 0

Views: 406

Answers (1)

Rob
Rob

Reputation: 437552

A couple of thoughts:

  1. Be careful when filtering the results of the call tree. You could have accidentally pruned out the routine with which the profiler associated the memory. Try (a) selecting the range of the graph that has the allocation in question (to reduce the amount of noise in the results); (b) removing the filter and then (c) expand the tree at that point where you see the large memory jump:

    look for jump

  2. Personally, I often find it easier to flip the call tree and hide system libraries:

    enter image description here

  3. Alternatively, you can also go to the "Statistics" of "Allocations" and find the big allocation:

    enter image description here

    You can then drill into that:

    enter image description here

    And then by clicking on the "Extended Detail" panel on the right, jump to the code in question:

    enter image description here

  4. If you want, another way to find allocations in Xcode 8 is to turn on the "Malloc Stack" option on your scheme and then use the "Debug Memory Graph" option as outlined in https://stackoverflow.com/a/30993476/1271826.

    For example, I used the "Debug Memory Graph", found the CG Raster Data, and I can see the object graph for this 10mb image, as well as can see the stack where this was allocated in the "Extended Details" panel on the right:

    enter image description here

Upvotes: 3

Related Questions