How much swap is a given Mac application using?

I've been googling alot ;-) As I understand it, the virtual memory of a given process is divided into pages that are handled by the OS and presented to the application as if it were RAM.

In OS X, based on the Mach kernel, this is handled by a daemon called dynamic_pager. This process generates the swapfile(s) in /private/var/vm as you mention. These swapfiles are not generated on a per application basis, but on a "need memory" basis. The swapfiles are divide into pages of 4096 bytes, and the pages are then allocated to the processes who (are deemed by the OS to) need virtual memory. Hence, you cannot associate a swapfile with a given application, but you can see how many pages a given process is using.

You might want to try the command vm_stat in Termial. This gives you a statistic of VM usage (note that 'page size' times number of pages active equals the size of your swapfile(s)). This also explains why you can have multiple processes using VM, but only a couple of swapfiles.

Other fun commands are vmmap [process id] and pagestuff.


The vmmap PID command should give you some helpful stats in numbers about a given process.


Based on the ideas posted here I created this little line of code:

sudo vmmap notifyd | grep -A3 'Summary'

which displays the Summary section (3 lines) of the vmmap output. I've used notifyd in this example, but you can replace that with any PID you know of.

This line will try to list all Summary lines of all running processes. Obviously some will fail because their process id is already gone (process ended), but in general i found this is a great way to scroll through a list of memory information and spot the top swapper.

ps -o pid= -xa | awk '{print $1}' | xargs -n 1 sudo vmmap | grep -A3 'Summary'

Edited: Some anonymous user saw this last command line needed an improvement because obviously the original variant did not work anymore. So thank you very much whoever you are and i'm sorry your edit was rejected. (First command previously read 'ps xa' and resulted in vmmap to fail because of the headline of ps being thrown at it)

Further improvement: If you like to know the name of the program right away use this small change

ps -o pid= -xa | awk '{print $1}' | xargs -n 1 sudo vmmap | egrep 'swapped_out|Path'

A little amendment on the other end of this command enables you to filter for certain program names or command line path components. Here we're looking at all processes from 'Library/PrivateFrameworks' only for example.

ps -o pid,command= -xa | grep 'Library/PrivateFrameworks' | awk '{print $1}' | xargs -n 1 sudo vmmap |