So I launched my app under Xcode with the Instruments Object Allocations template. My app finished, and I poked around in Instruments for a while, and everything seemed OK. Then I tried to save the trace document. Many minutes later, as Instruments remained unresponsive and my fans were getting noisy, I found that Instruments was in what seemed to be in an infinite loop logging:
Mar 21 10:15:10 Macintosh [0x0-0x148148].com.apple.Instruments[10418]: *** error: can't allocate region Mar 21 10:15:10 Macintosh [0x0-0x148148].com.apple.Instruments[10418]: *** set a breakpoint in malloc_error_break to debug Mar 21 10:15:10 Macintosh [0x0-0x148148].com.apple.Instruments[10418]: Instruments(10418,0xa0321fa0) malloc: *** mmap(size=432840704) failed (error code=12)
repeatedly (logged it about 1.25 million times before I force quit).
Anyone else run into this? Known problem? I'm using a MB Pro with 4G RAM.
It's something of an intractable problem. Memory logging tools like Instruments (and Shark, and Object Alloc before them, etc) do require a very large amounts of memory themselves, and it's not difficult for the target application to generate enough malloc activity to quickly overload them. They typically don't handle this gracefully, as you've noticed. :)
It's also not that uncommon to see situations like this, where recording the allocations succeeds, but the app blows up some time later while you're perusing the data or trying to save it.
Your best bet is to reduce the memory activity of your target app, e.g. by running it through a smaller dataset (if applicable), or recording for a shorter period. It's also useful to file bug reports ( http://bugreport.apple.com/) describing what you're trying to do, to give the developers of these tools an idea of why you're generating such large sets of data, which might help determine how the tools are improved in future.
If all else fails, keep "top -o vsize" open in a Terminal window, and when Instruments goes past some threshold - try 3 GiB to start with, working down if that's too much - stop recording. That should give you enough headroom to save the session.
Wade |