Nick Moore
Nick Moore

Reputation: 15857

Why is my Cocoa app using so much virtual memory?

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?

Upvotes: 0

Views: 484

Answers (2)

Peter Hosey
Peter Hosey

Reputation: 96363

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.

Upvotes: 2

VoidPointer
VoidPointer

Reputation: 17841

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.

Upvotes: 5

Related Questions