问题
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