come from:https://www.cnblogs.com/nibuyaoni/p/5724013.html
.bss段:程序中未初始化的和已经初始化为0的全局变量和已经初始化为0的静态局部变量(static)
.data段:程序中已经初始化的非零的全局变量和已经初始化的非零的静态局部变量(static)
代码段:用来存放代码的地方(.text段),不可修改,存放在只读区域内。
堆:程序员自己申请的内存区域,也就是用malloc()函数申请的内存区域,用free()函数来释放的区域。
栈:存放局部变量的区域,函数中的局部变量都是存放在栈中。
由SRAM的内存框图我们大概可以知道:栈在内存的最上区域,全局变量(数据段)在中间,(ZI段)bss段和堆(heap)在最下面的区域
注意:我们也可以自己写代码测试一下,每一种变量具体放在内存的哪个区域内。
come from : linux system environment programming
A virtual memory scheme splits the memory used by each program into small, fixed-size units called pages.
Correspondingly, RAM is divided into a series of page frames of the same size.
At any one time, only some of the pages of a program need to be resident in physical memory page frames; these pages form the so-called resident set.
Copies of the unused pages of a program are maintained in the swap area—a reserved area of disk space used to supplement the computer’s RAM—and loaded into physical memory only as required.
When a process references a page that is not currently resident in physical memory, a page fault occurs, at which point
the kernel suspends execution of the process while the page is loaded from disk into memory.