Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eternalstorms/3691979 to your computer and use it in GitHub Desktop.
Save eternalstorms/3691979 to your computer and use it in GitHub Desktop.
Activity Monitor memory usage is inaccurate
Monitoring your memory usage with Activity Monitor is pretty unreliable. First, which memory field are you watching (Virtual Private Memory, Real Private Memory, Real Shared Memory, or Real Memory)?
Second, when your code makes an allocation request, that typically goes, directly or indirectly, to the malloc routines. The malloc routines try to satisfy your request from the memory that it already has. If it can't then it requests more from the system. When you free memory, it goes back to malloc. Malloc does not necessarily return it to the system. It may keep it to more quickly satisfy future requests. So, you may not see your process's memory usage go down, at least not all the way, even if your program is releasing everything it allocated.
The proper way to check that your program is managing memory correctly is to use Instruments with the Leaks and Allocations tools.
(source: http://stackoverflow.com/questions/10218314/cocoa-memory-issue-memory-doesnt-get-reclaimed-when-objects-are-removed-from-a )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment