尽管内存未被进程本身使用,oom_reaper 总是会终止我们的应用程序。
在 OOM killer 终止进程之前,free -m 表示“shared”和“buff/cache”需要全部内存:
root@local:/tmp# free -m
total used free shared buff/cache available
Mem: 3861 627 95 3037 3138 26
Swap: 0 0 0
使用清除缓存echo 3 > /proc/sys/vm/drop_caches
不会产生任何作用。
linuxatemyram.com 不适用于此处。
我还已经通过使用排除了内存被 RAM 磁盘/tempfs 使用df -t tmpfs --total -h
。
在 OOM killer 终止进程之前,meminfo 返回了以下内容:
root@local:/tmp# awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t
MemTotal: 3861.26 MB
MemFree: 108.297 MB
MemAvailable: 49.6445 MB
Buffers: 2.82422 MB
Cached: 3069.16 MB
SwapCached: 0 MB
Active: 42.8164 MB
Inactive: 578.258 MB
Active(anon): 2.78125 MB
Inactive(anon): 542.719 MB
Active(file): 40.0352 MB
Inactive(file): 35.5391 MB
Unevictable: 2964.51 MB
Mlocked: 18.6484 MB
SwapTotal: 0 MB
SwapFree: 0 MB
Dirty: 0.09375 MB
Writeback: 0 MB
AnonPages: 513.977 MB
Mapped: 85.9766 MB
Shmem: 2987.97 MB
KReclaimable: 37.6602 MB
Slab: 104.531 MB
SReclaimable: 37.6602 MB
SUnreclaim: 66.8711 MB
KernelStack: 6.625 MB
PageTables: 11.4961 MB
NFS_Unstable: 0 MB
Bounce: 0 MB
WritebackTmp: 0 MB
CommitLimit: 1930.63 MB
Committed_AS: 5638.47 MB
VmallocTotal: 3.35544e+07 MB
VmallocUsed: 27.3516 MB
VmallocChunk: 0 MB
Percpu: 3.23438 MB
HardwareCorrupted: 0 MB
AnonHugePages: 0 MB
ShmemHugePages: 0 MB
ShmemPmdMapped: 0 MB
FileHugePages: 0 MB
FilePmdMapped: 0 MB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2 MB
Hugetlb: 0 MB
DirectMap4k: 179.078 MB
DirectMap2M: 3850 MB
ipcs -m --human 返回:
root@local:~# ipcs -m --human
------ Shared Memory Segments --------
key shmid owner perms size nattch status
0x00000000 2 user 600 512K 2 dest
0x00000000 262202 user 600 512K 2 dest
当我们的应用程序终止时,“buff/cache”和“shared”也会再次被释放。内存分析器也没有显示任何问题。我如何才能找出“shared”和“buff/cache”中有哪些数据?
系统:Ubuntu Server 20.04,5.11.0-41-generic(HWE)