问题:公司一台服务器发现内存占用过高但是查不出来哪个进程,ps 和 top 命令。
处理方法:
(1)cat /proc/meminfo
MemTotal: 3924684 kB MemFree: 419016 kB Buffers: 2208 kB Cached: 30688 kB SwapCached: 0 kB Active: 87516 kB Inactive: 7408 kB Active(anon): 62052 kB Inactive(anon): 448 kB Active(file): 25464 kB Inactive(file): 6960 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 364 kB Writeback: 0 kB AnonPages: 62072 kB Mapped: 23752 kB Shmem: 460 kB Slab: 3363472 kB SReclaimable: 3333552 kB SUnreclaim: 29920 kB KernelStack: 1296 kB PageTables: 4540 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 1962340 kB Committed_AS: 246680 kB VmallocTotal: 34359738367 kB VmallocUsed: 18660 kB VmallocChunk: 34359702432 kB HardwareCorrupted: 0 kB AnonHugePages: 14336 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 6016 kB DirectMap2M: 2091008 kB DirectMap1G: 2097152 kB
发现slab 占用过高
(2)执行 slabtop 发现 dentry 占用过高
(3)执行 cat /proc/sys/fs/dentry-state 查看状态
(4)执行 echo 2 > /proc/sys/vm/drop_caches 内存得到释放。
参考文章:https://developer.aliyun.com/article/131870