0
$ sudo smem -t -m > m; head -n5 m; echo; tail m

Map                                       PIDs   AVGPSS      PSS 
/dev/dri/card0                               2        0        0 
/dev/shm/org.chromium.0P27rF                 1        0        0 
/dev/shm/org.chromium.1LwGBc                 1        0        0 
/dev/shm/org.chromium.23Bqe3                 1        0        0 

/dev/shm/org.mozilla.ipc.23887.6343          2     6772    13544 
/dev/shm/org.mozilla.ipc.23935.491           2     6772    13544 
/memfd:gdk-wayland                           6     2890    17344 
/SYSV00000000                                6     3759    22556 
/usr/lib64/firefox/libxul.so                14     8711   121956 
/i915                                        4    38494   153976 
[heap]                                     208     3201   665971 
<anonymous>                                222    15859  3520738 
-----------------------------------------------------------------
1698                                     20333   280628  5056008

What is the 3.5 GB of "<anonymous>" memory usage in this system, that is not counted as "[heap]" (666M)?


Total Shmem (which includes all tmpfs files and GEM buffers) is "only" about 608M ("608004 kB").

$ uname -r  # Kernel version
5.0.17-200.fc29.x86_64

$ cat /proc/meminfo
MemTotal:        8042664 kB
MemFree:          426436 kB
MemAvailable:    2521060 kB
Buffers:          266884 kB
Cached:          2576424 kB
SwapCached:        14624 kB
Active:          4242740 kB
Inactive:        2647644 kB
Active(anon):    3097748 kB
Inactive(anon):  1561596 kB
Active(file):    1144992 kB
Inactive(file):  1086048 kB
Unevictable:      203436 kB
Mlocked:           13700 kB
SwapTotal:       2097148 kB
SwapFree:        1472816 kB
Dirty:               112 kB
Writeback:             0 kB
AnonPages:       4241276 kB
Mapped:           760472 kB
Shmem:            608004 kB
KReclaimable:     165768 kB
Slab:             332388 kB
SReclaimable:     165768 kB
SUnreclaim:       166620 kB
KernelStack:       21552 kB
PageTables:        47628 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     6118480 kB
Committed_AS:   15395448 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
Percpu:             3424 kB
HardwareCorrupted:     0 kB
AnonHugePages:   1796096 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      483892 kB
DirectMap2M:     7782400 kB
DirectMap1G:     1048576 kB
K7AAY
  • 3,816
  • 4
  • 23
  • 39
sourcejedi
  • 50,249

1 Answers1

2

You can filter for it.

$ sudo smem -t -M "<anonymous>" > M; head -n5 M; echo; tail M
  PID User     Command                         Swap      USS      PSS      RSS 
 2098 alan     /usr/libexec/gdm-wayland-se      232        0        0        0 
11759 alan-sysop /usr/libexec/gdm-wayland-se      232        0        0        0 
 2306 alan     /usr/libexec/ibus-dconf          244        4        4        4 
 2322 alan     /usr/libexec/xdg-permission      232        4        4        4 

23887 alan     /usr/lib64/firefox/firefox         0    67508    67508    67508 
20206 alan     /usr/lib64/firefox/firefox         0    67960    67960    67960 
25791 alan-sysop /usr/lib64/firefox/firefox         0    68176    68176    68176 
 2673 alan     /usr/bin/gnome-software --g    50184   125620   125620   125620 
 2220 alan     /usr/bin/gnome-shell           16768   139076   139076   139076 
25686 alan-sysop /usr/lib64/firefox/firefox         0   212396   212396   212396 
19977 alan     /usr/lib64/firefox/firefox         0   250900   250900   250900 
21812 qemu     /usr/bin/qemu-system-x86_64        0  1813964  1813964  1813964 
-------------------------------------------------------------------------------
  221 11                                     195308  3471748  3472326  3473492 

The largest user is a QEMU virtual machine. However that only accounts for half of it. All sorts of programs are using some memory like this. Looking at the full list (as written to the file M), I saw plenty of traditional old programs including crond, atd, agetty, and bash.

It might reflect large malloc() allocations (a 4096 byte page or more) being allocated directly using mmap().

So, it is probably best to view [heap] as a special subset of <anonymous>. And to not think of <anonymous> as being something strange.

sourcejedi
  • 50,249
  • 1
    linux will only report as "[heap]" the memory between start_brk and brk -- look at fs/proc/task_mmu.c:show_map_vma. You can retrieve the former from /proc/PID/stat. –  Jun 14 '19 at 17:07