See details of an app's virtual size

Oct 19, '12 07:30:00AM

Contributed by: robg

If you use top in Terminal, you may occasionally see apps with huge VSIZE values. I know this because Witch, one of our apps, is an example of such—it's VSIZE can exceed 11GB.

In trying to figure out why this was so (short answer seems to be: we can't control it, but it's not a problem), I ran across an interesting command, vmmap. This command will spew out a ton of detail about virtual memory usage. Stringing a couple Unix commands together, though, you can extract just the summary portion of the report.

In Terminal, run this command:

vmmap -resident PID# | grep "Summary for" -A 999
Replace PID# with the process ID you're interested in observing, and you'll get a nice summary of its virtual memory state. You can see what's virtual, and what's actually resident. Here's a bit of the output for Witch, for example:
...
REGION TYPE                      VIRTUAL RESIDENT
===========                      ======= ========
...
CG shared images                   1280K    1256K
CoreGraphics                         16K       8K
CoreServices                       6232K    6232K
IOKit (reserved)                  256.0M       0K
MALLOC                            337.3M    7932K
MALLOC (reserved)                   7.8G       0K
MALLOC freed, no zone              72.0M     212K
MALLOC guard page                   104K       0K
...
As you can see, although Witch has an 11GB virtual size, the biggest chunk (7.8GB) isn't using an real RAM—and best as I can tell, will never use any real RAM.

In doing my research, I found a couple of articles (1,2) that discuss large VSIZE values, and how they shouldn't be of concern. (The first linked article is where I ran into the vmmap command.)

Still, it's odd that this only happens to some apps, not all. Enlightenment welcomed, if you happen to be a virtual memory expert!

Comments (1)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20121016063646746