Mapping /proc/meminfo to output of free command

So an example output of free is

                             total             used             free                shared    buffers     cached
Mem:                     12333980   12151544    182436          0            233128    11197680
-/+ buffers/cache:                     720820        11613160
Swap:                    487416       3536             483880

And /proc/meminfo

MemTotal:       12333980 kB
MemFree:          182436 kB
Buffers:          233128 kB
Cached:         11197680 kB
SwapCached:          996 kB
Active:          7296040 kB
Inactive:        4231216 kB
Active(anon):      73848 kB
Inactive(anon):    22892 kB
Active(file):    7222192 kB
Inactive(file):  4208324 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:        487416 kB
SwapFree:         483880 kB
Dirty:               268 kB
Writeback:             0 kB
AnonPages:         95640 kB
Mapped:          7686976 kB
Shmem:               292 kB
Slab:             346296 kB
SReclaimable:     335352 kB
SUnreclaim:        10944 kB
KernelStack:        1920 kB
PageTables:        23844 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     6654404 kB
Committed_AS:     613716 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      309052 kB
VmallocChunk:   34359422748 kB
HardwareCorrupted:     0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       10240 kB
DirectMap2M:    12572672 kB

I’ve done my best to match up the two outputs via colors. Below you will find the math used if there is any.

Total Memory

No math needed.. follow the colors

Used Memory

So for this we want to find the math used to get the used memory on the +/- buffers line. This is the true RAM used by the system.

So this math is based on output of the cat /proc/meminfo

MemTotal - (Buffers + Cached + MemFree)

So our example would be

12333980 - (182352 + 233128 + 11197680) = 720820

Free Memory

So for this we want to find the math used to get the free memory on the +/- buffers line. This is the true RAM that can be used by applications that request it. The operating system will remove data from here to give to applications on demand.

So this math is based on output of the cat /proc/meminfo

Cached + Buffers + MemFree

So our example would be

182352 + 233128 + 11197680 = 11613160

Total Swap

No math needed.. follow the colors

Used Swap

So to find out what free is outputting is pretty simple just do the math from the meminfo output

SwapTotal - SwapFree

So that would look like

487416 - 483880 = 3536

Free Swap

No math needed.. follow the colors

About mike
Currently works for OpenSky as a Senior Linux Admin. He has a wonderful wife Thanuja and 2 great dogs. His major side project is Photoblog.

Comments

One Response to “Mapping /proc/meminfo to output of free command”
  1. harry says:

    It is not the case for android os. With android OS, I have the following output:
    [root@172.17.0.223: ]# cat /proc/meminfo
    MemTotal: 400384 kB
    MemFree: 3248 kB
    Buffers: 26344 kB
    Cached: 160196 kB
    SwapCached: 0 kB
    Active: 118188 kB
    Inactive: 121752 kB
    Active(anon): 40604 kB
    Inactive(anon): 40612 kB
    Active(file): 77584 kB
    Inactive(file): 81140 kB
    Unevictable: 27280 kB
    Mlocked: 0 kB
    SwapTotal: 0 kB
    SwapFree: 0 kB
    Dirty: 0 kB
    Writeback: 0 kB
    AnonPages: 80712 kB
    Mapped: 96160 kB
    Shmem: 536 kB
    Slab: 16204 kB
    SReclaimable: 7592 kB
    SUnreclaim: 8612 kB
    KernelStack: 2392 kB
    PageTables: 3396 kB
    NFS_Unstable: 0 kB
    Bounce: 0 kB
    WritebackTmp: 0 kB
    CommitLimit: 200192 kB
    Committed_AS: 1777048 kB
    VmallocTotal: 1441792 kB
    VmallocUsed: 66616 kB
    VmallocChunk: 1351676 kB
    [root@172.17.0.223: ]# free
    total used free shared buffers
    Mem: 400384 388832 11552 0 24032
    -/+ buffers: 364800 35584
    Swap: 0 0 0

    I tried very hard to find an answer, coudn’t get it right.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!