Linux - Memory

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.

Concept

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.

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.

Management

See

By Process

The first 10 process by memory

ps aux --sort -rss | head -10

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

With free

with the free command

total        used        free      shared  buff/cache   available
Mem:            62G         16G        772M        613M         46G         45G
Swap:          2.0G        1.2G        854M





Discover More
Linux - Free command (Memory)

Free is a linux command that display amount of free and used memory in the system The Mem: row displays physical memory utilization, The Swap: row displays the utilization of the system swap space,...



Share this page:
Follow us:
Task Runner