进程内存布局

可以通过一下方法查看:

命令:

  • pmap

文件:

  • proc filesystem maps

使用 pmap

可以从其说明看到 -X 也是从/proc/PID/smaps获取了更详细的信息

[root@centosgpt ~]# pmap  1704
1704:   -bash
0000000000400000    884K r-x-- bash
00000000006dd000      4K r---- bash
00000000006de000     36K rw--- bash
...
00007f3c65515000     28K r--s- gconv-modules.cache
00007f3c6551c000      4K rw--- [ anon ]
00007f3c6551d000      4K r---- ld-2.17.so
00007f3c6551e000      4K rw--- ld-2.17.so
00007f3c6551f000      4K rw--- [ anon ]
00007ffd64655000    132K rw--- [ stack ]
00007ffd64769000     12K r---- [ anon ]
00007ffd6476c000      4K r-x-- [ anon ]
ffffffffff600000      4K r-x-- [ anon ]
 total           115580K

查看 proc filesystem maps

/proc/PID/smaps

[root@centosgpt ~]# cat /proc/1704/maps
00400000-004dd000 r-xp 00000000 fd:00 1138              /usr/bin/bash
006dd000-006de000 r--p 000dd000 fd:00 1138              /usr/bin/bash
006de000-006e7000 rw-p 000de000 fd:00 1138              /usr/bin/bash
...
7f3c6551d000-7f3c6551e000 r--p 00021000 fd:00 33593974  /usr/lib64/ld-2.17.so
7f3c6551e000-7f3c6551f000 rw-p 00022000 fd:00 33593974  /usr/lib64/ld-2.17.so
7f3c6551f000-7f3c65520000 rw-p 00000000 00:00 0
7ffd64655000-7ffd64676000 rw-p 00000000 00:00 0         [stack]
7ffd64769000-7ffd6476c000 r--p 00000000 00:00 0         [vvar]
7ffd6476c000-7ffd6476d000 r-xp 00000000 00:00 0         [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]