Linux下查看程序内存占用
2017-01-15 22:30
309 查看
1
使用ps命令查看内存是不准确的,因为其返回的是一个进程所用的所有空间,而由于linux的共享内存机制,一个资源可能并非一个程序所独占。[详见]结果显示中常出现的RSS和VSZ的区别。
- RSS:Resident Set Size 进程在RAM中占用的空间,不包括swap中的部分,包含共享内存中实际装载的部分,包含所有的栈和堆空间。单位KB
- VSZ : Virtual Memory Size 包括了进程所有可使用的空间,单位KB
举例说明:某程序有500K的binary,实际装载200K,链接到了2500K的共享库文件,实际装载了1000K,有200K的栈和堆占用,其中100K在内存中,剩余的是swapped。
RSS: 400K+1000K+100K
VSZ : 500K+2500K+200K
[详见]
2
使用pmap命令。Usage: pmap [options] PID [PID ...] Options: -x, --extended show details -X show even more details WARNING: format changes according to /proc/PID/smaps -XX show everything the kernel provides -c, --read-rc read the default rc -C, --read-rc-from=<file> read the rc from file -n, --create-rc create new default rc -N, --create-rc-to=<file> create new rc to file NOTE: pid arguments are not allowed with -n, -N -d, --device show the device format -q, --quiet do not display header and footer -p, --show-path show path in the mapping -A, --range=<low>[,<high>] limit results to the given range -h, --help display this help and exit -V, --version output version information and exit
如下为cmake的占用内存
mapped: 670196K writeable/private: 80988K shared: 9368K
3
使用cat /proc/PID/statmsize (1) total program size (same as VmSize in /proc/[pid]/status)
resident (2) resident set size (same as VmRSS in /proc/[pid]/status)
shared (3) number of resident shared pages (i.e., backed by a file) (same as RssFile+RssShmem in /proc/[pid]/status)
text (4) text (code)
lib (5) library (unused since Linux 2.6; always 0)
data (6) data + stack
dt (7) dirty pages (unused since Linux 2.6; always 0)
例子 693 406 586 158 0 535 0
[详见]
4
使用valgrind工具,生成程序运行时的快照5
使用toptop -p <PID>
6
使用smem命令有USS和PSS两种,USS是独占的内存,PSS还包含了按比例分得的共享内存。
相关文章推荐
- Linux 命令 之查看程序占用内存
- 如何在linux中查看程序占用的内存
- 在linux下,怎么去查看一个运行中的程序, 到底是占用了多少内存
- 在linux下,查看一个运行中的程序, 占用了多少内存
- Linux下查看某一个程序运行所占用的内存
- linux下查看程序占用多少内存
- Linux下查看某一个程序运行所占用的内存
- linux下查看运行程序的内存空间
- Linux查看程序端口占用情况
- linux下查看哪些程序占用sdcard or usb
- Linux查看程序端口占用情况
- 查看linux被隐藏进程的内存占用方法,可用于监控进程是否内存泄漏
- LINUX进程内存占用查看
- 怎样正确查看Linux的内存占用情况
- Linux 查看当前占用CPU或内存最多的5个进程
- Linux查看某一程序所占的内存—top
- Linux:pmap命令,查看进程占用的内存及使用地址空间(转)
- linux 下查看端口占用程序
- 怎样正确查看Linux的内存占用情况
- Linux查看程序端口占用情况