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 mem开发者_JS百科ory.
I am using garbage collection. I link to the AppKit.framework. Is this normal or is there something I am doing wrong?
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.
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.
精彩评论