[英]Find out which process is using shared memory
I wonder about the shared memory is currently using in the system so I run the command: 我不知道系统中当前正在使用共享内存,因此我运行以下命令:
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
--> total shared memory 7555480 bytes = 7555.48 kB ->总共享内存7555480字节= 7555.48 kB
and then run cat /proc/meminfo |grep -i 然后运行cat / proc / meminfo | grep -i
cat /proc/meminfo |grep -i shmem<br/>
Shmem: 21592 kB
as I see, there is a gap between the total shared memory in ipcs -m, which i could not understand which process is using could you help me on this? 如我所见,ipcs -m中的总共享内存之间存在差距,我无法理解正在使用哪个进程,您能帮我这个忙吗?
Thank you 谢谢
shmem includes more than ipc shared memory segments, for example things like a ramdisk. shmem不仅包括ipc共享内存段,例如ramdisk。
/proc/pid/statm - third field indicates how much shared memory pages a process has. / proc / pid / statm-第三个字段指示一个进程具有多少共享内存页。 Example code: 示例代码:
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 is page size from getconf PAGESIZE
4096是getconf PAGESIZE
页面大小
See https://lists.kernelnewbies.org/pipermail/kernelnewbies/2013-July/008628.html and https://access.redhat.com/solutions/406773 for more possibilities. 有关更多可能性,请参阅https://lists.kernelnewbies.org/pipermail/kernelnewbies/2013-July/008628.html和https://access.redhat.com/solutions/406773 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.