views:

118

answers:

2

I have written a simple Cocoa app. In Activity Monitor, it is shown to be using a lot more virtual memory than all other apps: 304.6MB. (It uses this from the get-go, so I don't think it's a memory leak/management issue). Thing like Firefox, Mail etc. are only using 30MB-60MB or so. My app is using 13MB real memory.

I am using garbage collection. I link to the AppKit.framework. Is this normal or is there something I am doing wrong?

+5  A: 

The "Virtual Memory" stat for a process counts everything that the process has mapped. This includes any shared libraries and so forth (these memory pages are shared with other processes). To get an idea about how much memory your process has actually allocated privately, look at the "Real Private Memory" stat.

VoidPointer
+2  A: 

It's not.

Every garbage-collected app gets very large numbers under the VPRVT (“Virtual Memory” in Activity Monitor) and VSIZE columns. This is normal and harmless. Your application's actual memory usage is under “Real Memory”.

See this post on cocoa-dev by Bill Bumgarner where he explains why garbage-collected apps appear to use so much memory.

Peter Hosey