Memory pages used by a process in Linux

蹲街弑〆低调 提交于 2019-12-12 22:05:36

问题


I want to get the list of all mapped pages (allocated memory) in a Linux Process at runtime. How can I do that?


回答1:


From inside the process, on Linux, you can read and parse /proc/self/maps ; try cat /proc/self/maps which will show you the memory map of the process running that cat

From another process, for the map of the process of pid 1234, you can read /proc/1234/maps

And there is also /proc/self/smaps etc.

The Linux specific dladdr function is sometimes useful also.

If you are concerned by pages which are really in RAM, use mincore & msync




回答2:


You can use /proc/[PID]/maps for this.




回答3:


/proc/$your_pid/maps and examine other files in /proc/$your_pid they may be useful too



来源:https://stackoverflow.com/questions/8510648/memory-pages-used-by-a-process-in-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!