Memory not being released in a timely manner
Memory not being released in a timely manner
- Subject: Memory not being released in a timely manner
- From: Jonathan Taylor <email@hidden>
- Date: Mon, 03 Jun 2013 16:59:55 +0100
Hi all,
Can anybody advise what tools I should be using to debug a particular out of memory condition - and maybe even how I can fix it? The error that I ultimately encounter (in a 32-bit application on Snow Leopard) is:
2013-06-03 15:44:30.271 MyApplication[25115:a0f] NSImage: Insufficient memory to allocate pixel data buffer of 1228800 bytes
However as I'll explain I don't feel that I am doing anything that should result in running out of memory.
The program loads and processes a large number (~2000) image files, and I believe that I am disposing of memory and draining autorelease pools correctly. Running the program under ObjectAlloc, it never reports memory usage over 300MB. The problem seems to be that, even though ObjectAlloc thinks the memory has been released, it is not actually being properly freed up until some time later. The memory usage as reported in Activity Monitor climbs higher and higher until, if left unattended, there is apparently no more memory available. Clicking the mouse or switching applications causes an immediate and significant drop in memory usage.
Thus the situation seems to be that I believe I am doing everything I can for good memory management, but the OS is not actually freeing things up for re-use. I encountered a similar problem that I asked about on here last year:
http://lists.apple.com/archives/cocoa-dev/2012/Jul/msg00602.html
Although in that case the eventual conclusion was that I should be using a different approach in my code, it involved the same issue of memory not being released when I would have expected it to be. In that case from last year, I was wrong to rely on it being released when I expected, but I feel that this time it should be reasonable to expect that I won't run out of memory entirely, given that I am releasing all the buffers that I am finished with and only keeping a small working set allocated!
This is of course partly just speculation because ObjectAlloc isn't giving any info about this unavailable but apparently not-allocated memory. So...
1. Can anybody recommend a way of debugging this problem to get more concrete evidence for what is actually happening?
2. Assuming my interpretation is correct, can anybody suggest a solution?
Many thanks
Jonny
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden