找出一个进程在Linux上使用了多少页内存 [英] Find out how many pages of memory a process uses on linux

查看:84
本文介绍了找出一个进程在Linux上使用了多少页内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找出一个进程分配了多少页内存? 每页是4096,我在查找正确值时遇到一些进程内存使用问题.当我在gome-system-monitor中查看时,可以在内存映射下选择一些值.

谢谢.

这样做的目的是将内存使用量除以页数并验证页大小.

解决方案

很难准确地确定正确分配的内存量:有些页面与其他进程(库的r/o部分)共享,从未使用过brk和匿名mmap,由于高效的处理算法(仅接触文件的一小部分等),换出的页面,要在磁盘上写入的脏页面等原因,无法从磁盘完全获取映射的文件.

如果您想处理所有这些复杂性并弄清页面的真实计数,请在/proc/<pid>/smaps上找到详细信息,并且可以通过mem_usage.pysmem.pl之类的工具(很容易找到)来打开它成为或多或少可用的摘要.

I need to find out how many pages of memory a process allocates? Each page is 4096, the process memory usage I'm having some problems locating the correct value. When I'm looking in the gome-system-monitor there are a few values to choose from under memory map.

Thanks.

The point of this is to divide the memory usage by the page count and verify the page size.

解决方案

It's hard to figure exact amount of memory allocated correctly: there are pages shared with other processes (r/o parts of libraries), never used memory allocated by brk and anonymous mmap, mmaped file which are not fetched from disk completely due to efficient processing algorithms which touch only small part of file etc, swapped out pages, dirty pages to-be-written-on-disk etc.

If you want to deal with all this complexity and figure out True count of pages, the detailed information is available at /proc/<pid>/smaps, and there are tools, like mem_usage.py or smem.pl (easily googlable) to turn it into more-or-less usable summary.

这篇关于找出一个进程在Linux上使用了多少页内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆