linux和windows内存布局验证
来源:互联网 发布:android性能优化工具 编辑:程序博客网 时间:2024/06/16 05:03
#if 1
//内存布局的验证
#include <stdio.h>
int globle_init = 0;
int globle_uinit;
static int globle_static = 0;
int main()
{
int local_init = 0;
static int local_static = 0;
int *local_ptr;
local_ptr = (int *)malloc(10);
printf("address of main is %p\n", main);
printf("address of globle_init is %p\n", &globle_init);
printf("address of globle_uinit is %p\n", &globle_uinit);
printf("address of globle_static is %p\n", &globle_static);
printf("address of local_init is %p\n", &local_init);
printf("address of local_static is %p\n", &local_static);
printf("address of &local_ptr is %p\n", &local_ptr);
printf("address of local_ptr is %p\n", local_ptr);
//////////////////////////////////////////////////////////////////////////
/*
//windows
address of &local_ptr is0031FB70 stack
address of local_init is0031FB7C stack
address of local_ptr is00378820 heap
address of main is00AD1145 text
address of globle_init is 00AD8130 data
address of globle_static is 00AD8134data
address of local_static is 00AD8138data
address of globle_uinit is 00AD8160data
//linux
address of local_init is0x7fff4397784c stack
address of &local_ptr is0x7fff43977840 stack
address of local_ptr is0x828010 heap
address of globle_uinit is0x601064 data
address of local_static is0x601060 data
address of globle_static is 0x60105cdata
address of globle_init is0x601058 data
address of main is0x400650 text
*/
//////////////////////////////////////////////////////////////////////////
free(local_ptr);
printf("ok\n");
return 0;
}
#endif
//内存布局的验证
#include <stdio.h>
int globle_init = 0;
int globle_uinit;
static int globle_static = 0;
int main()
{
int local_init = 0;
static int local_static = 0;
int *local_ptr;
local_ptr = (int *)malloc(10);
printf("address of main is %p\n", main);
printf("address of globle_init is %p\n", &globle_init);
printf("address of globle_uinit is %p\n", &globle_uinit);
printf("address of globle_static is %p\n", &globle_static);
printf("address of local_init is %p\n", &local_init);
printf("address of local_static is %p\n", &local_static);
printf("address of &local_ptr is %p\n", &local_ptr);
printf("address of local_ptr is %p\n", local_ptr);
//////////////////////////////////////////////////////////////////////////
/*
//windows
address of &local_ptr is0031FB70 stack
address of local_init is0031FB7C stack
address of local_ptr is00378820 heap
address of main is00AD1145 text
address of globle_init is 00AD8130 data
address of globle_static is 00AD8134data
address of local_static is 00AD8138data
address of globle_uinit is 00AD8160data
//linux
address of local_init is0x7fff4397784c stack
address of &local_ptr is0x7fff43977840 stack
address of local_ptr is0x828010 heap
address of globle_uinit is0x601064 data
address of local_static is0x601060 data
address of globle_static is 0x60105cdata
address of globle_init is0x601058 data
address of main is0x400650 text
*/
//////////////////////////////////////////////////////////////////////////
free(local_ptr);
printf("ok\n");
return 0;
}
#endif
0 0
- linux和windows内存布局验证
- Linux内存布局
- linux进程内存布局
- Linux内存布局
- linux进程内存布局
- mini2440 linux 内存布局
- 2Linux内存布局
- linux内存布局
- Linux内存布局
- 重温 linux内存布局
- Linux内存布局
- Linux 内存的布局
- linux进程内存布局
- Linux的内存布局
- linux进程内存布局
- linux应用程序内存布局
- Linux内存布局
- Linux内存布局
- Bootstrap中的JavaScript
- LeetCode Pascal's Triangle
- Java sleep wait 在多线程中的区别
- ECharts+BaiduMap+HT for Web网络拓扑图应用
- CSS基础:基本选择器分类和使用
- linux和windows内存布局验证
- poj(2299)——Ultra-QuickSort(归并排序求逆序数)
- 使用Android Studio导入源码
- 十一第四题Single Number III
- Xcode7适配iOS9遇到的一些问题及解决办法
- Linux free命令
- Android--Intent常用(拨号,浏览器,联系人,Wi-Fi)
- iOS数据库使用(sqlite3)
- LightOJ 1259 Goldbach`s Conjecture