我有 32GB RAM 的 Linux 机器。据top显示,只有9.264 GB是免费的
GiB Mem : 31.423 total, 9.264 free, 20.670 used, 1.490 buff/cache
GiB Swap: 1.076 total, 1.076 free, 0.000 used. 10.543 avail Mem
但顶部的进程列表对于 RES 来说总共只有 102.1 MB,对于 VIRT 来说总共只有 3251.6 MB。
如何确定哪些内容正在使用剩余内存?
以下是其他一些内存检查:
vmstat 1 5
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 9714504 179376 1382620 0 0 3 19 34 37 4 1 95 0 0
0 0 0 9714400 179376 1382652 0 0 0 0 42 80 0 0 100 0 0
0 0 0 9714400 179376 1382652 0 0 0 0 48 89 0 0 100 0 0
0 0 0 9714400 179376 1382652 0 0 0 0 37 72 0 0 100 0 0
0 0 0 9714400 179376 1382652 0 0 0 0 36 63 0 0 100 0 0
cat /proc/meminfo
MemTotal: 32949560 kB
MemFree: 9714532 kB
Buffers: 179376 kB
Cached: 1311020 kB
SwapCached: 0 kB
Active: 1078684 kB
Inactive: 457080 kB
Active(anon): 46016 kB
Inactive(anon): 8356 kB
Active(file): 1032668 kB
Inactive(file): 448724 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 1128444 kB
SwapFree: 1128444 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 45416 kB
Mapped: 30660 kB
Shmem: 9008 kB
Slab: 71632 kB
SReclaimable: 57932 kB
SUnreclaim: 13700 kB
KernelStack: 848 kB
PageTables: 3548 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 17603224 kB
Committed_AS: 318636 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 197832 kB
VmallocChunk: 34359533592 kB
HardwareCorrupted: 0 kB
AnonHugePages: 4096 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 44992 kB
DirectMap2M: 33509376 kB
更新 平板报告:
Active / Total Objects (% used) : 253008 / 257418 (98.3%)
Active / Total Slabs (% used) : 8361 / 8361 (100.0%)
Active / Total Caches (% used) : 70 / 99 (70.7%)
Active / Total Size (% used) : 62949.41K / 64953.55K (96.9%)
Minimum / Average / Maximum Object : 0.01K / 0.25K / 16.12K
OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME
67314 67314 100% 0.10K 1726 39 6904K buffer_head
40131 39973 99% 0.19K 1911 21 7644K dentry
26316 26316 100% 0.11K 731 36 2924K sysfs_dir_cache
22432 22432 100% 0.96K 1402 16 22432K ext4_inode_cache
11456 11456 100% 0.06K 179 64 716K kmalloc-64
9180 9180 100% 0.04K 90 102 360K ext4_extent_status
8848 8284 93% 0.57K 316 28 5056K inode_cache
8463 7478 88% 0.19K 403 21 1612K kmalloc-192
6944 6944 100% 0.07K 124 56 496K Acpi-ParseExt
6784 6457 95% 0.03K 53 128 212K kmalloc-32
6144 6144 100% 0.01K 12 512 48K kmalloc-8
5292 5198 98% 0.55K 189 28 3024K radix_tree_node
5120 5120 100% 0.02K 20 256 80K kmalloc-16
3864 3232 83% 0.07K 69 56 276K anon_vma
3774 3774 100% 0.04K 37 102 148K Acpi-Namespace
3488 2866 82% 0.25K 218 16 872K kmalloc-256
2635 2635 100% 0.05K 31 85 124K shared_policy_node
2048 1681 82% 0.12K 64 32 256K kmalloc-128
1806 1806 100% 0.09K 43 42 172K kmalloc-96
1248 1109 88% 0.50K 78 16 624K kmalloc-512
1200 1160 96% 0.63K 48 25 768K proc_inode_cache
1200 1200 100% 0.66K 50 24 800K shmem_inode_cache
1152 1101 95% 1.00K 72 16 1152K kmalloc-1024
1152 1152 100% 0.11K 32 36 128K jbd2_journal_head
570 443 77% 0.81K 30 19 480K task_xstate
512 512 100% 0.03K 4 128 16K jbd2_revoke_record_s
480 397 82% 6.00K 96 5 3072K task_struct
475 475 100% 0.62K 19 25 304K sock_inode_cache
448 350 78% 2.00K 28 16 896K kmalloc-2048
420 314 74% 1.06K 14 30 448K signal_cache
378 378 100% 0.38K 18 21 144K blkdev_requests
357 357 100% 0.08K 7 51 28K Acpi-State
351 351 100% 0.10K 9 39 36K blkdev_ioc
340 340 100% 0.05K 4 85 16K jbd2_journal_handle
320 320 100% 0.06K 5 64 20K kmem_cache_node
320 320 100% 0.06K 5 64 20K ext4_free_data
300 300 100% 0.13K 10 30 40K ext4_allocation_context
270 270 100% 1.75K 15 18 480K TCP
256 256 100% 0.02K 1 256 4K jbd2_revoke_table_s
224 224 100% 0.07K 4 56 16K ext4_io_end
219 219 100% 0.05K 3 73 12K ip_fib_trie
210 210 100% 2.06K 14 15 448K sighand_cache
204 204 100% 0.12K 6 34 24K fsnotify_event
195 195 100% 2.06K 13 15 416K idr_layer_cache
187 187 100% 0.94K 11 17 176K UNIX
184 184 100% 0.09K 4 46 16K fscache_cookie_jar
175 175 100% 0.31K 7 25 56K mnt_cache
170 170 100% 0.02K 1 170 4K numa_policy
152 138 90% 4.00K 19 8 608K kmalloc-4096
150 150 100% 0.62K 6 25 96K files_cache
144 144 100% 0.25K 9 16 36K kmem_cache
120 120 100% 1.06K 4 30 128K UDPv6
112 112 100% 1.94K 7 16 224K TCPv6
110 110 100% 0.73K 5 22 80K cifs_inode_cache
108 108 100% 0.88K 6 18 96K mm_struct
100 100 100% 0.16K 4 25 16K sigqueue
96 96 100% 0.32K 4 24 32K taskstats
96 96 100% 0.25K 6 16 24K dquot
90 90 100% 0.44K 5 18 40K xfrm_dst_cache
84 84 100% 2.21K 6 14 192K blkdev_queue
76 76 100% 0.81K 4 19 64K bdev_cache
72 72 100% 0.88K 4 18 64K UDP
更新2
输出smem -R 32G -w
Area Used Cache Noncache
firmware/hardware 605196 0 605196
kernel image 0 0 0
kernel dynamic memory 24459656 2776744 21682912
userspace memory 73964 22308 51656
free memory 8415616 8415616 0
答案1
尝试
ps aux --sort -rss
以 root 身份运行。
ps aux --sort -rss | wc -l
当我这样做时,我的输出与我以 root 身份运行时的输出不同。
此外...我发现这个命令很有帮助。
ps -eo size,pid,user,command --sort -size | \
awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' |\
cut -d "" -f2 | cut -d "-" -f1
答案2
请检查您是否在 RAM 上创建了任何文件系统
执行 df -TPh,检查 tmpfs、ramfs.. 通常是 RAM FS,检查这些 FS 的使用情况,以防有任何情况
例子:
# df -TPh
tmpfs tmpfs 512M 256M 256M 50% /mnt/ramdisk
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm