I have a strange memory problem. I am having problems resolving the problem, and I would appreciate some recommendations as to where else to look.
The program that I have (iPhone application) has a function thanks to which it downloads most of the files, processes those that are JSON, and saves the rest to disk. JSON processing has processor intensity and can take several seconds for each file, so I have an NSOperationQueue with a maxConcurrency limited to 1 that handles all the heavy lifting, and a queue that manages multiple uploaded files.
Since the release of iOS5, the application has had problems with completing the boot sequence without failures, and so far I have tried:
1) The processing of performSelectorOnBackgroundThread JSON has been changed to use one NSOperationQueue to limit the number of background threads working with large objects.
2) Added NSAutoReleasePools inside loops that create several large, transient objects.
3) Dropped sharedURLCache so that the files do not hang in the system cache.
4) Saved JSON objects to disk using NSKeyedArchiver and passed the file names between the streams rather than the actual objects in order to try again to reduce the number and size of the stored objects that are currently in use.
It all seemed to matter at first, and when I look at the memory allocation, I now have peak usage from just over 20 MB (hence itโs not surprising that this is a failure) to less than 10 MB, and yet the application still crashes with low memory, as before.
I am trying to trace that there is a memory due to which the application crashed, and in this case I am having real problems convincing the Tools to tell me something useful.
Here's a typical trace (on iPhone 3GS running iOS 4.3.5)

You can see that using PEAK was just over 7 MB, but soon after that you can see two flags related to low memory, then low memory urgently, and then the application soon stopped.
If I use a memory monitor, the cause of the failure seems clear enough - the physical memory is exhausted - look at the light green trail below. Low memory alerts accompany (unsurprisingly) when physical memory runs out.

There are no leaks showing FWIW (I did this in other runs).
This is not image caching or NSURLConnection caching, and the only thing I can think of is that maybe there are some bad leaks that cannot be detected ... but I am having trouble identifying them, because if I click on all distributions to see objects that are alive, and then run the -A command to select them all (to paste them into a spreadsheet to see where the memory is located), the moment I press the-C command to copy them Playing a beach ball and never recovering It is.
I really cannot understand what is happening. Does anyone have any tips on how to convince the tools to show me more useful information about what this memory uses?
Sorry, I canโt post any meaningful snippets of code ... I hope the screenshots on the tools will at least give you an idea of โโwhere I come from.