Mapping /proc/meminfo to output of free command

May 29, 2012   

So an example output of free is

                             total             used             free                shared    buffers     cached
Mem:                     <span style="color: #039b3d">12333980</span>   12151544    182436          0            <span style="color: #06e572">233128</span>    <span style="color: #5656ff">11197680</span>
-/+ buffers/cache:                     720820        11613160
Swap:                    <span style="color: #005fbf">487416</span>       3536             <span style="color: #56aaff">483880</span>

And /proc/meminfo

<span style="color: #039b3d">MemTotal:       12333980 kB</span>
MemFree:          182436 kB
<span style="color: #06e572">Buffers:          233128 kB</span>
<span style="color: #5656ff">Cached:         11197680 kB</span>
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
<span style="color: #005fbf">SwapTotal:        487416 kB</span>
<span style="color: #56aaff">SwapFree:         483880 kB</span>
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) = <strong>720820</strong>

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 = <strong>11613160</strong>

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



comments powered by Disqus