LINUX中的过程工作集信息 [英] Process Working Set Info in LINUX
问题描述
我想在LINUX上运行的C ++应用程序中获取给定PID的内存工作集值。在Windows中,我可以使用 GetProcessWorkingSetSize
函数获取此信息。有什么像这样的功能我可以在LINUX中调用?
I am trying to obtain the memory working set value for a given PID in my C++ application running on LINUX. In Windows I can get this info using GetProcessWorkingSetSize
function. Is there anything like this function I can call in LINUX?
推荐答案
想到的唯一明智的解决方案是访问相关信息通过 / proc
文件系统。看起来很奇怪,一个进程将不得不从 / proc
中读出自己的信息,但我不知道任何其他系统调用可能使这更容易。
The only sensible solution that comes to mind is accessing the relevant information via the /proc
filesystem. It seems weird that a process would have to read out its own information from /proc
, though, but I don't know about any other system calls that might make this easier.
您可能最感兴趣的信息位于 / proc / [pid] / statm
包括:
The information you're probably most interested in is located in /proc/[pid]/statm
, which includes :
- 总计划规模,
- 常住套餐大小,
- 共享页面
- 文字(代码)大小
- b
- 数据和堆栈大小,
- 脏页(在Linux 2.6中未使用)。
- total program size,
- resident set size,
- shared pages,
- text (code) size,
- library (unused in Linux 2.6),
- data and stack size,
- dirty pages (unused in Linux 2.6).
请记住,所有这些度量都以页数表示。
Keep in mind that all those measurements are given in the number of pages.
这篇关于LINUX中的过程工作集信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!