4

When I cat /proc/meminfo, the report as follows:

MemTotal:        2034284 kB
MemFree:         1432728 kB
Buffers:           16568 kB
Cached:           324864 kB
SwapCached:            0 kB
Active:           307344 kB
Inactive:         256916 kB
Active(anon):     223020 kB
Inactive(anon):    74372 kB
Active(file):      84324 kB
Inactive(file):   182544 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:       1152648 kB
HighFree:         600104 kB
LowTotal:         881636 kB
LowFree:          832624 kB
SwapTotal:       4200960 kB
SwapFree:        4200960 kB
Dirty:                60 kB
Writeback:             0 kB
AnonPages:        222868 kB
Mapped:            80596 kB
Shmem:             74564 kB
Slab:              24268 kB
SReclaimable:      14024 kB
SUnreclaim:        10244 kB
KernelStack:        1672 kB
PageTables:         2112 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     5218100 kB
Committed_AS:     833352 kB
VmallocTotal:     122880 kB
VmallocUsed:       13916 kB
VmallocChunk:      50540 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       4096 kB
DirectMap4k:       20472 kB
DirectMap4M:      888832 kB

I got a formula to calculate the Memtotal:

Memtotal = MemFree + Cached + Active + Inactive + Mapped + Shmem + Slab + PageTables + VmallocUsed

but I don't know the formula is correct or not, any one can help to clarify it?

sarnold
  • 102,305
  • 22
  • 181
  • 238
stefan_weids
  • 41
  • 1
  • 2
  • possible duplicate of [How do I account for all of the memory in meminfo?](http://stackoverflow.com/questions/10406691/how-do-i-account-for-all-of-the-memory-in-meminfo) – sarnold May 09 '12 at 02:02
  • Incidentally, on my system I get: `342136 + 4121640 + 2786880 + 2446580 + 95700 + 11644 + 280100 + 17252 + 304180 == 10406112`. But `10406112 != 6111456`. I don't think the math is quite right yet. :) – sarnold May 09 '12 at 02:05

1 Answers1

2

I think it would be difficult to reach to the exact value (addition based total memory validation) from meminfo. Nonetheless, in my view following should lead you close to TotalMemory figure.

TotalMemory = MemFree + Buffers + Cached + Dirty + AnonPages + Slab + VmAllocUsed

In your example case 1432728 + 16568 + 324864 + 60 + 222868 + 24268 + 13916 = 2035272 Some ref : http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/proc.txt?id=HEAD#l451 (From another stackoverflow article suggested above) Apart from that, I believe the volatility is because of VmAllocUsed.

Anugraha Sinha
  • 621
  • 6
  • 13