views:

79

answers:

5

Hi, Is there a shell command to know about how much memory is being used at a particular moment and details of how much each process is using, how much virtual memory is left etc?

+1  A: 

Depends on your operating system. In Linux, free answers two out of your three questions.

~> free
             total       used       free     shared    buffers     cached
Mem:        904580     895128       9452          0      63700     777728
-/+ buffers/cache:      53700     850880
Swap:       506036          0     506036

"Swap" refers to virtual memory.

unwind
thanks a lot for that...
assassin
+2  A: 

For "each process", how about top:

PhysMem: 238M wired, 865M active, 549M inactive, 1652M used, 395M free.
VM: 162G vsize, 1039M framework vsize, 124775(0) pageins, 9149(0) pageouts.

PID   COMMAND      %CPU TIME     #TH  #WQ  #POR #MREG RPRVT  RSHRD  RSIZE  VPRVT  VSIZE  PGRP PPID STATE    UID
7233  top          5.7  00:00.53 1/1  0    24   33    1328K  264K   1904K  17M    2378M  7233 3766 running  0  

e.g.:

rprvt  Resident private address space size.
rshrd  Resident shared address space size.
rsize  Resident memory size.
vsize  Total memory size.
vprvt  Private address space size.
Ramashalanka
thanks a lot.... top did the job for me..
assassin
+1  A: 

Let's also hear it for the old classic, vmstat.

$ vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0  30160  15884 418680 281936    0    0   406    22    6    3  1  1 93  5
Teddy
ya... vmstat does the job too.. thanks.
assassin
A: 

If you are on an up-to-date Linux, cat /proc/$pid/smaps is the business.

If you are on OSX, check http://superuser.com/questions/97235/how-much-swap-is-a-given-mac-application-using.

Charles Stewart
A: 

If you're on Linux, give ps_mem.py a try.

pixelbeat