文件名称:differenct
介绍说明--下载内容均来自于网络,请自行研究使用
堆和栈的区别
一、预备知识—程序的内存分配
一个由c/C++编译的程序占用的内存分为以下几个部分
1、栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等。其操作方式类似于数据结构中的栈。
2、堆区(heap) — 一般由程序员分配释放, 若程序员不释放,程序结束时可能由OS回收 。注意它与数据结构中的堆是两回事,分配方式倒是类似于链表,呵呵。
3、全局区(静态区)(static)—,全局变量和静态变量的存储是放在一块的,初始化的全局变量和静态变量在一块区域, 未初始化的全局变量和未初始化的静态变量在相邻的另一块区域。 - 程序结束后有系统释放
4、文字常量区—常量字符串就是放在这里的。 程序结束后由系统释放
5、程序代码区—存放函数体的二进制代码。
二、例子程序
-reactors and the distinction between a stack, prior knowledge-memory allocation procedures from a c/C compiler procedures occupied by the memory is divided into the following sections 1, Stack (stack)- automatically by the compiler release distribution, storage function parameters, local variables, such as the value. Their mode of operation similar to the data structure of the stack. 2, the reactor (heap)- General to release the allocation by programmers, programmers if not released at the end of proceedings by the OS may recall. Attention to its data structure and the reactor are two different things, but similar to the distribution chain, Ha ha. 3, the overall situation (static) (static)-, global variables and static variables are stored on one, initialize the global variables and s
一、预备知识—程序的内存分配
一个由c/C++编译的程序占用的内存分为以下几个部分
1、栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等。其操作方式类似于数据结构中的栈。
2、堆区(heap) — 一般由程序员分配释放, 若程序员不释放,程序结束时可能由OS回收 。注意它与数据结构中的堆是两回事,分配方式倒是类似于链表,呵呵。
3、全局区(静态区)(static)—,全局变量和静态变量的存储是放在一块的,初始化的全局变量和静态变量在一块区域, 未初始化的全局变量和未初始化的静态变量在相邻的另一块区域。 - 程序结束后有系统释放
4、文字常量区—常量字符串就是放在这里的。 程序结束后由系统释放
5、程序代码区—存放函数体的二进制代码。
二、例子程序
-reactors and the distinction between a stack, prior knowledge-memory allocation procedures from a c/C compiler procedures occupied by the memory is divided into the following sections 1, Stack (stack)- automatically by the compiler release distribution, storage function parameters, local variables, such as the value. Their mode of operation similar to the data structure of the stack. 2, the reactor (heap)- General to release the allocation by programmers, programmers if not released at the end of proceedings by the OS may recall. Attention to its data structure and the reactor are two different things, but similar to the distribution chain, Ha ha. 3, the overall situation (static) (static)-, global variables and static variables are stored on one, initialize the global variables and s
(系统自动生成,下载前可以参看下载内容)
下载文件列表
堆和栈的区别.txt