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