I have a system with 1 GB of physical RAM. Right now, free shows the following memory usage:

             total       used       free     shared    buffers     cached
Mem:       1026360     863660     162700          0          0      50216
-/+ buffers/cache:     813444     212916
Swap:      5242876     500648    4742228

So except the block cache, 813 MB are used. /proc/meminfo (which I'll post at the bottom due to length) tells me that, of this, 283 MB are mapped into userland processes (AnonPages + Mapped), and that 127 MB are used by the kernel (Slab + KernelStack + PageTables).

That still leaves ~400 MB unaccounted for, however. Are my conceptions of how the system uses memory somewhat correct? Is there a way to tell what half of my memory is used for?

MemTotal:        1026360 kB
MemFree:          193768 kB
Buffers:               0 kB
Cached:            28932 kB
SwapCached:       101208 kB
Active:           178816 kB
Inactive:         182476 kB
Active(anon):     167196 kB
Inactive(anon):   168184 kB
Active(file):      11620 kB
Inactive(file):    14292 kB
Unevictable:        9848 kB
Mlocked:            9848 kB
SwapTotal:       5242876 kB
SwapFree:        4739272 kB
Dirty:                24 kB
Writeback:             0 kB
AnonPages:        268280 kB
Mapped:            14832 kB
Shmem:               280 kB
Slab:             111828 kB
SReclaimable:      27432 kB
SUnreclaim:        84396 kB
KernelStack:        2280 kB
PageTables:        13200 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     5756056 kB
Committed_AS:    1506036 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      145004 kB
VmallocChunk:   34359581976 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       79808 kB
DirectMap2M:      968704 kB

I use a little awk get the top10 memory users based on the resident set size (RSS) that is the amount of memory a process actually uses in your servers RAM (without swapped pages):

awk '{ printf "%8d %8d %8d pid:%-5d comm:%-10s state:%c\n",$14,$15,$24,$1,$2,$3; }' /proc/[1-9]*/stat |sort -rn -k3 |sed 10q

without the sed 10q you get the full list of processes sorted descending.

The RSS is the 3rd column in the output. Possibly you need to fix the field numbers for your kernel based on man 5 proc.

  • As I extracted the information in the question, I similarly summed the RSS of all processes with ps -A l | awk '{s += $8;} END {print s;}', and it ended up at 303 MB, pretty closely matching the result of AnonPages + Mapped that I posted (the difference, I can only assume, being due to sharing). I'm not sure how that answers anything, though. – Dolda2000 Jul 10 '15 at 5:25
  • Interesting point. I will take a look at it later. I would blindly vote for shared libraries too. – ikrabbe Jul 10 '15 at 5:45
  • All that memory is part of AnonPages, and shared libraries are part of Mapped. – Gilles 'SO- stop being evil' Jul 10 '15 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.