一、内存布局图
二、源码【存为mi.cpp】
#include <stdio.h>
#include <malloc.h>
#include <unistd.h>
int bss_var;
int data_var0=1;
int main(int argc, char** argv)
{
}
三、编译
[erlang@m176com duan]$ g++ -o mi mi.cpp
四、运行
[erlang@m176com duan]$ ./mi
below are addresses of types of process's mem
----------------------------------------------------------
Code location:
----------------------------------------------------------
Data Location:
----------------------------------------------------------
BSS Location:
----------------------------------------------------------
Heap Location:
----------------------------------------------------------
Stack Location:
----------------------------------------------------------
五、看一下内存段信息
[erlang@m176com duan]$ ps -efa|grep mi|grep erlang|grep -v grep|awk '{print $2}'
13371
[erlang@m176com duan]$ cat /proc/13371/maps
005eb000-00600000 r-xp 00000000 68:05 2689943
00600000-00601000 r-xp 00015000 68:05 2689943
00601000-00602000 rwxp 00016000 68:05 2689943
00609000-0072e000 r-xp 00000000 68:05 2689944
0072e000-0072f000 r-xp 00124000 68:05 2689944
0072f000-00732000 rwxp 00125000 68:05 2689944
00732000-00734000 rwxp 00732000 00:00 0
00736000-00757000 r-xp 00000000 68:05 2689945
00757000-00759000 rwxp 00020000 68:05 2689945
008b2000-008b9000 r-xp 00000000 68:05 2689948
008b9000-008ba000 rwxp 00007000 68:05 2689948
009cd000-00a8d000 r-xp 00000000 68:05 2941513
00a8d000-00a92000 rwxp 000bf000 68:05 2941513
00a92000-00a98000 rwxp 00a92000 00:00 0
08048000-08049000 r-xp 00000000 68:05 6342667
08049000-0804a000 rw-p 00000000 68:05 6342667
0996f000-09991000 rw-p 0996f000 00:00 0
b7fc3000-b7fc5000 rw-p b7fc3000 00:00 0
b7fdb000-b7fdc000 rw-p b7fdb000 00:00 0
bff61000-c0000000 rw-p bff61000 00:00 0
ffffe000-fffff000 ---p 00000000 00:00 0
六、分页存储管理【是从百度文库中摘录的,在此向作者致敬】
http://wenku.baidu.com/view/b7db25687e21af45b307a899
FROM: http://blog.sina.com.cn/s/blog_49f761940100nzr4.html