Linux - Memory

1 - About

Process memory reports on Linux are difficult to interpret for various reasons. One of the main reasons is the way processes can share or re-use memory allocated to another process. Linux normally allocates separate memory areas to different processes, of course. There are two main exceptions to this rule.

3 - Concept

3.1 - Program code

When several processes use the same code libraries, there will only be one copy of that code in physical memory, re-used by all the processes.

3.2 - Shared memory

The second exception is a shared memory:

  • Does it belong to one process? Both? Neither? If we naively sum the memory belonging to multiple processes, we grossly “over-count”.
  • Linux reports shared memory inconsistently. When you ask it to report the resident memory map of a single process, it will report the shared-memory as part of its memory footprint. However, when you ask “how much total memory is resident”, it does not account for shared memory.

This is usually not significant, because very few programs use large blocks of shared memory.

4 - Articles Related

5 - Management

5.1 - See

5.1.1 - With /proc/meminfo

Type Kb
MemTotal 65960736
MemFree 619152
MemAvailable 47707620
Buffers 190928
Cached 10569080
SwapCached 14316
Active 19988984
Inactive 7073804
Active(anon) 15443864
Inactive(anon) 1486776
Active(file) 4545120
Inactive(file) 5587028
Unevictable 0
Mlocked 0
SwapTotal 2097148
SwapFree 874696
Dirty 316
Writeback 4
AnonPages 16288656
Mapped 203568
Shmem 627856
Slab 37646316
SReclaimable 37498424
SUnreclaim 147892
KernelStack 33136
PageTables 60980
NFS_Unstable 0
Bounce 0
WritebackTmp 0
CommitLimit 35077516
Committed_AS 17919820
VmallocTotal 34359738367
VmallocUsed 255600
VmallocChunk 34359318220
HardwareCorrupted 0
AnonHugePages 606208
HugePages_Total 0
HugePages_Free 0
HugePages_Rsvd 0
HugePages_Surp 0
Hugepagesize 2048
DirectMap4k 210880
DirectMap2M 22857728
DirectMap1G 46137344

5.1.2 - With free

              total        used        free      shared  buff/cache   available
Mem:            62G         16G        772M        613M         46G         45G
Swap:          2.0G        1.2G        854M
os/linux/memory.txt · Last modified: 2018/10/25 16:11 by gerardnico