查看进程内存空间

C语言的编译过程

逻辑地址和物理地址

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>

int global_var = 5;

int main() {
static int static_var = 6;
int local_var = 7;
int* p = (int*)malloc(100);

// Be careful: we must use %lx to show a 64bits address!!
printf("the global_var address is %lx\n", (unsigned long)&global_var);
printf("the static_var address is %lx\n", (unsigned long)&static_var);
printf("the local_var address is %lx\n", (unsigned long)&local_var);
printf("the address which the p points to %lx\n", (unsigned long)p);

free(p);

// We need to watch the process state, so let it sleep deeply.
sleep(1000);

return 0;
}

进程的内存映像


查看进程内存空间
http://example.com/2023/12/02/查看进程内存空间/
作者
Forrest
发布于
2023年12月2日
许可协议