0

I'm trying to memory test my app.

I've followed the Organizer - Documentation article entitled "Recovering Memory You Have Abandoned", but I'm not sure if the results make my tested page good or bad, or somewhere in-between.

(My test involved: navigate to page 2, going back to page 1, press 'Mark Heap' -repeated 25 times for good measure.)

Attached is a screenshot of my allocations test. Most of the #Persistent values are 0. But there are some anomalies. Are these typical?

(The last Heapshot, 26, was taken after stopping the recording, and pressing 'Mark Heap' at the end of the trace - as suggested in the documentation.)

I would be very grateful for some advice. Thanks.

enter image description here

Custom Bonbons
  • 1,609
  • 2
  • 12
  • 17

1 Answers1

2

I believe that you are using ARC, and if you are using ARC, there is no need of bothering about the heaps, it will take care of everything.

Here are the 9 simple points from Apple's docs to be in mind while using ARC:

ARC imposes some new rules that are not present when using other compiler modes. The rules are intended to provide a fully reliable memory management model; in some cases, they simply enforce best practice, in some others they simplify your code or are obvious corollaries of your not having to deal with memory management. If you violate these rules, you get an immediate compile-time error, not a subtle bug that may become apparent at runtime.

  1. You cannot explicitly invoke dealloc, or implement or invoke retain, release, retainCount, or autorelease. The prohibition extends to using @selector(retain), @selector(release), and so on.

  2. You may implement a dealloc method if you need to manage resources other than releasing instance variables. You do not have to (indeed you cannot) release instance variables, but you may need to invoke [systemClassInstance setDelegate:nil] on system classes and other code that isn’t compiled using ARC. Custom dealloc methods in ARC do not require a call to [super dealloc] (it actually results in a compiler error). The chaining to super is automated and enforced by the compiler.

  3. You can still use CFRetain, CFRelease, and other related functions with Core Foundation-style

  4. You cannot use NSAllocateObject or NSDeallocateObject.

  5. You create objects using alloc; the runtime takes care of deallocating objects.

  6. You cannot use object pointers in C structures. Rather than using a struct, you can create an Objective-C class to manage the data instead. There is no casual casting between id and void *.

  7. You must use special casts that tell the compiler about object lifetime. You need to do this to cast between Objective-C objects and Core Foundation types that you pass as function arguments. For more details, see “Managing Toll-Free Bridging.”

  8. You cannot use NSAutoreleasePool objects. ARC provides @autoreleasepool blocks instead. These have an advantage of being more efficient than NSAutoreleasePool.

  9. You cannot use memory zones. There is no need to use NSZone any more—they are ignored by the modern Objective-C runtime anyway.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Charan
  • 4,940
  • 3
  • 26
  • 43
  • Thanks sree. Also, in case it helps anyone. I have ran the same test, using established purchased apps, and the results are very similar. Which is reassuring. :) – Custom Bonbons Aug 15 '12 at 11:28
  • 2
    "I believe that you are using ARC, and if you are using ARC, there is no need of bothering about the heaps, it will take care of everything." No, ARC does not take care of everything for you: http://stackoverflow.com/questions/6260256/what-kind-of-leaks-does-automatic-reference-counting-in-objective-c-not-prevent and there are many, many cases where looking at heap shots can still point out memory accumulation. All of my applications are ARC-enabled, yet I still heavily rely on heap shots to find retain cycles, leaked CF objects, etc. – Brad Larson Aug 22 '12 at 18:52