Skip navigation.
 
mlRe: Memory footprint and -leakage of Cocoa Apps
FROM : Timothy J.Wood
DATE : Thu Apr 14 18:34:06 2005

On Apr 14, 2005, at 4:31 AM, Alex v.Below wrote:
> - Why do MallocDebug and ObjectAlloc say 1.8 MB are allocated, when 
> activity viewer shows much more? Who can I trust?


  MallocDebug and ObjectAlloc are showing *heap* allocations while 
Activity Viewer is showing virtual memory allocations.  The later 
includes the executable code for your application and all the 
frameworks you use, and any VM allocations done by low level operations 
(that bypass the memory allocation logging hooks).

> - How can I reduce this initial memory footprint? I am using two 
> standard frameworks, (Cocoa and SystemConfiguration), and the actual 
> executable is a measly 52 kBytes.


  It's really only worth trying to reduce the total heap allocation and 
resident size of your code.  So, make sure your data structures are 
allocated efficiently and possibly try compiling your code with the -Os 
optimization flag (optimize for size).  You can't do anything about the 
VM eaten by Cocoa, nor should you worry about it since it really is 
shared even though it gets counted against you in this case.

> - The answer to this can only be generic, but where can I find more 
> info on finding memory leaks, or unnecessary allocations in my Cocoa 
> code? I found a number of leaks in my code with MallocDebug and was 
> able to verify that they had been fixed. But this does not seem to be 
> the entire story, as my application still seems hungry for memory.


  There are a bunch of tools that can help:

   - Shark (see developer.apple.com)
   - OmniObjectMeter (see omnigroup.com -- disclaimer: written by me :)
   - vmmap/heap/leaks/malloc_history (see the man pages)

  The developer docs also have some tips on memory performance -- see 
the last couple links on 
<file:///Developer/ADC%20Reference%20Library/documentation/Performance/
Conceptual/PerformanceFundamentals/index.html#//apple_ref/doc/uid/
10000147i>


-tim

Related mailsAuthorDate
mlMemory footprint and -leakage of Cocoa Apps Alex v.Below Apr 14, 13:31
mlRe: Memory footprint and -leakage of Cocoa Apps Timothy J.Wood Apr 14, 18:34