assassin
assassin

Reputation: 21169

querying for memory details in shell

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?

Upvotes: 2

Views: 2400

Answers (5)

Teddy
Teddy

Reputation: 6163

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

Upvotes: 3

Charles Stewart
Charles Stewart

Reputation: 11837

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

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

Upvotes: 0

pixelbeat
pixelbeat

Reputation: 31718

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

Upvotes: 0

Ramashalanka
Ramashalanka

Reputation: 8864

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.

Upvotes: 3

unwind
unwind

Reputation: 399833

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.

Upvotes: 2

Related Questions