我这里有一台服务器,它有一个高内存使用率警报(所有内存的 95% 正在被使用),但我找不到它的使用位置。 java进程消耗了所有内存的62%,但我找不到另一半内存在哪里,尽管它没有用于缓冲/缓存
[user@server ~]$ free -m
total used free shared buff/cache available
Mem: 11203 10832 138 2 231 106
Swap: 48639 1338 47301
[user@server ~]$
top - 02:54:33 up 82 days, 3:51, 1 user, load average: 10.14, 9.91, 9.72
Tasks: 253 total, 1 running, 123 sleeping, 0 stopped, 0 zombie
%Cpu(s): 67.8 us, 1.7 sy, 0.0 ni, 30.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
GiB Mem : 99.1/10.9 [||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ]
GiB Swap: 2.8/47.5 [||| ]
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
17177 root 20 0 14.1g 6.8g 11.4m S 826.9 62.5 4543:35 java
18518 root 20 0 7735.9m 196.6m 0.0m S 0.0 1.8 65:35.73 java
20307 root 20 0 569.8m 26.4m 9.1m S 0.7 0.2 1:12.77 gc-fastpath
26954 SRV_Lin+ 20 0 343.0m 25.5m 0.0m S 0.3 0.2 44:05.60 splunkd
23541 guardic+ 20 0 407.5m 9.4m 6.4m S 0.0 0.1 13:10.17 gc-guardig
13449 root 20 0 224.1m 5.1m 2.9m S 0.0 0.0 59:39.38 snmpd
10558 root 20 0 157.7m 4.6m 3.2m S 0.0 0.0 0:00.03 sshd
1764 root 20 0 190.9m 4.5m 2.0m S 0.0 0.0 58:08.11 vmtoolsd
27200 ladmsrv+ 20 0 158.4m 4.5m 3.7m R 0.0 0.0 0:00.08 top
19229 guardic+ 20 0 281.3m 3.5m 0.3m S 0.3 0.0 16:31.04 gc-guest-agent
934 root 20 0 102.8m 3.4m 3.2m S 0.0 0.0 1:33.63 systemd-journal
10667 ladmsrv+ 20 0 112.9m 3.1m 2.6m S 0.0 0.0 0:00.00 bash
1 root 20 0 123.9m 3.1m 1.2m S 0.0 0.0 20:09.97 systemd
10666 ladmsrv+ 20 0 157.7m 2.7m 1.4m S 0.0 0.0 0:00.01 sshd
2046 root 20 0 560.8m 2.5m 0.0m S 0.0 0.0 8:43.78 tuned
[user@server ~]$ cat /proc/meminfo
MemTotal: 11471940 kB
MemFree: 148316 kB
MemAvailable: 113900 kB
Buffers: 4912 kB
Cached: 130952 kB
SwapCached: 206420 kB
Active: 6478044 kB
Inactive: 1104480 kB
Active(anon): 6405872 kB
Inactive(anon): 1043240 kB
Active(file): 72172 kB
Inactive(file): 61240 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 49807356 kB
SwapFree: 48438780 kB
Dirty: 236 kB
Writeback: 0 kB
AnonPages: 7435712 kB
Mapped: 65588 kB
Shmem: 2444 kB
Slab: 3337628 kB
SReclaimable: 99628 kB
SUnreclaim: 3238000 kB
KernelStack: 9872 kB
PageTables: 25980 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 55543324 kB
Committed_AS: 9062736 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 5253120 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
DirectMap4k: 864128 kB
DirectMap2M: 11161600 kB
DirectMap1G: 1048576 kB
答案1
请检查您是否安装了任何基于内存的文件系统,例如 tmpfs,以及它们上是否有大量数据。例如,Fedora 已经将 tmpfs 用于 /tmp 相当长一段时间了,如果上面有很多临时文件,这可以解释为什么内存不足。
例如这里:
$ mount | grep tmpfs
devtmpfs on /dev type devtmpfs (rw,relatime,seclabel,size=32896392k,nr_inodes=8224098,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=49396572k)
tmpfs on /var/tmp type tmpfs (rw,nosuid,nodev,relatime,seclabel)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=6586208k,mode=700,uid=1000,gid=1000)
$ df /tmp
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 49396572 91052 49305520 1% /tmp
上面的“ Used
”将从您的免费 RAM 中扣除。