(下列介紹由記憶體位置高排到低)
●heap
●stack
通常是給動態記憶配置(dynamic memory allocation)使用,需要programmer自己申請.
●stack
區域變數(local variable)
函式參數(function/method parameter)
函數的返回位址(function/method return address)
Keil官方手冊: 3.4 Stack use in C and C++
函式參數(function/method parameter)
函數的返回位址(function/method return address)
Keil官方手冊: 3.4 Stack use in C and C++
●bss (uninitialized data)
●data (initialized data)
●text code (text segment)
CPU instructions stored in here.
const int a = 1; //stored in data int b = 1; //stored in data int c; //stored in bss int main(void) { const static int w = 1; //stored in data static int x = 1; //stored in data static int y; //stored in bss int z = 1; //stored in stack int *buffer = (char*) malloc(sizeof(char) * 10); //stored in heap }
沒有留言:
張貼留言