15

What does "Memory" usage chart/graph exactly represents in XCode 5 Debug navigator window?

I have an iOS app project with ARC disabled and no-storyboard/xib (i.e. old style). All memory management done manually using retain/release/autorelease.

When I debug the project in XCode 5, the memory pie-chart / graph show gradually increasing memory usage as the app runs, exceeds 1 GB memory footprints within half hour.

Roughly, it keeps increasing by 0.1 to 0.3 MB per 2 to 3 second with very rare memory dips/decrease (of magnitude < 0.1 MB per 30 seconds).

enter image description here

Is this a concern (memory leak) with respect to memory management? I did memory analysis (using Allocations/Memory Leak through Instruments on XCode 4.6) but didn't find any leaks.

Ashok
  • 6,224
  • 2
  • 37
  • 55

3 Answers3

48

Found answer myself. Unfortunately I had NSZombieEnabled (Zombie object) for debug mode - see below - (menu Product > Scheme > Edit Scheme)

enter image description here

Typically NSZombieEnabled tool keeps even the released objects in memory to help developer find over released objects. Refer this link - What is NSZombie?

After I unchecked "Enable Zombie Objects" option, the memory usage stabilized to about 10 mb (not always increasing) even after half hour app usage - see below -

enter image description here

BOTTOM LINE - Ensure to clear "Enable Zombie Objects" when you want to analyze memory usage.

Community
  • 1
  • 1
Ashok
  • 6,224
  • 2
  • 37
  • 55
  • 1
    FWIW, this was killing me. Obviously my release being profiled didn't match the same memory usage that Xcode displayed in my Debug build that had zombies enabled. Thanks for this. – migs647 Dec 10 '13 at 01:50
  • 1
    This is a revelation. Thank you so much. – Stavash Jan 07 '14 at 11:23
  • Thank you for pointing this out. I was going nuts as I'd profile in Instruments and not see the same thing. I did check Enable Zombie Objects a while back. – VaporwareWolf Feb 06 '14 at 23:02
  • 1
    Are you sure it works? When Zombie objects enabled - memory progress isn't displayed in debug navigator (at least XCODE 6) – Injectios Nov 07 '14 at 14:20
  • very helpful!, Disabling Zombie objects in Xcode 8.2 shows the memory graph again. – Alfred Schilken Dec 14 '16 at 11:49
3

It simply measures the memory your app uses. So if it is increasing it must be a memory leak.

When using the leak analysis tools, I would use it as a guideline. It may help you find leaks but with all automated tools it may not find it all. As certain pieces of code (Especially the more dynamic pieces) may be hard to predict what they do memory wise for an automated tool.

Malloc
  • 15,434
  • 34
  • 105
  • 192
James Campbell
  • 3,511
  • 4
  • 33
  • 50
  • When I analyzed in XCode 4.6 Instruments, it showed total memory usage going close to 1.5 GB but active memory column showing usage close to 2-3 MB only. Also, memory leak didn't flag any blots. What tool or practice would you recommend to catch this (leak!)? – Ashok Oct 16 '13 at 02:27
  • 1
    Don't test on the iOS Simulator as it can be inaccurate is one suggestion. But here are some video links explaining situations where the memory leak instrument may not capture memory leaks. Part1: http://www.youtube.com/watch?v=4tvEFwWItQU Part 2 : http://www.youtube.com/watch?v=HBvBL_m2-5k – James Campbell Oct 16 '13 at 07:17
  • In Part 2 he recommends to use the analyse option as it can pick up memory leaks that cannot be picked up by the instruments tool. – James Campbell Oct 16 '13 at 07:23
  • These videos are useful (+1). Let me analyze & confirm your answer before I 'check' this answer. Stay tuned! :) – Ashok Oct 16 '13 at 20:39
  • Found the real issue in my case (See my checked answer). However, I agree with your explanation in general (+1). – Ashok Oct 17 '13 at 15:13
1

I am seeing an issue where memory (heap) grows indefinitely on heavy processing but when running the exact same binary without Xcode; memory usage is fine. Remember to test outside of Xcode -- no idea what the cause is. NSZombies and all other debug options are off.

lupinglade
  • 481
  • 5
  • 11