How to find out about the contents of autoreleasepools on iOS?

Viewed 443

I'm looking to decrease the memory usage of my app, and one place we might be wasting memory is in our use of autoreleasepools. I think we have them everywhere appropriate right now, but I'm not certain, so I'd like to do some measurement at strategic points and see if more @autoreleasepool blocks would be useful.

I've done some research and found out about the following methods of investigating autoreleasepools, which may have worked in the past but apparently do not any more, at least in XCode 5:

  • +[NSAutoreleasePool showPools] - this is meant to print information about the active autoreleasepools, but doesn't seem to do anything any more - XCode doesn't think it's a thing

  • _objc_autoreleasePoolPrint - I've found a few references to this function on stack overflow, but XCode insists that it doesn't exist, and won't link against it if I declare it as extern

Our codebase is big enough that just sticking extra autoreleasepools everywhere would be a fools errand, so what I'm looking for is a way to find out how many objects are "in the pool" at any particular time. That way I can add more pools to the few places that need them, rather than throwing them everywhere.

If I have to be in Instruments or the debugger to find that out, that's not a problem - this is just something we'd use for testing, and wouldn't go out in a release.

Thanks for your help!

1 Answers
Related