我想知道共享内存当前正在系统中使用,所以我运行命令:
ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x50040150 2195456 user-owner 660 65648 2
0x00000000 2228225 user-owner 660 32768 1
0x00000000 2260994 user-owner 660 1052672 1
0x00000000 2293763 user-owner 660 57304 2
0x00000000 2326532 user-owner 660 98256 1
0x00000000 2359301 user-owner 660 53184 1
0x00000000 2392070 user-owner 660 98416 2
0x00000000 2424839 user-owner 660 98416 2
0x00000000 2457608 user-owner 660 672000 2
0x00000000 2490377 user-owner 660 672000 2
0x00000000 2523146 user-owner 660 672000 2
0x00000000 2555915 user-owner 660 672000 2
0x00000000 2588684 user-owner 660 672000 2
0x00000000 2621453 user-owner 660 672000 2
0x00000000 2654222 user-owner 660 672000 2
0x00000000 2686991 user-owner 660 672000 2
0x43040150 2719760 user-owner 660 304 1
0x00000000 2752529 user-owner 660 32768 1
0x00000000 2785298 user-owner 660 266240 1
0x00000000 2818067 user-owner 660 49104 1
0x00000000 2850836 user-owner 660 167920 2
0x00000000 2883605 user-owner 660 102384 2
0x013352ab 720918 user-owner 666 4096 2
- >总共享内存7555480字节= 7555.48 kB
然后运行cat / proc / meminfo | grep -i
cat /proc/meminfo |grep -i shmem<br/>
Shmem: 21592 kB
如我所见,ipcs -m中的总共享内存之间存在差距,我无法理解哪个进程正在使用 你能帮帮我吗?
谢谢
答案 0 :(得分:0)
shmem包含的不仅仅是ipc共享内存段,例如ramdisk。
/ proc / pid / statm - 第三个字段表示进程拥有多少共享内存页。示例代码:
cd /proc
for i in `ls -d * | grep -v self`
do
if [[ -f $i/statm ]];then
echo -n "$i "; cat $i/statm | perl -lan -e 'print ($F[2] * 4096)';
fi
done | sort -nr -k2 | head
4096是getconf PAGESIZE
参见https://lists.kernelnewbies.org/pipermail/kernelnewbies/2013-July/008628.html 和https://access.redhat.com/solutions/406773以获得更多可能性。