摘要
使用C++编程时,内存分为五个区:堆、栈、自由存储区、全局/静态存储区与常量存储区。用new来分配堆,用delete来释放;它的操作灵活,可用空间大,但容易产生碎片。栈由编译器自动分配释放,有专门的入栈出栈指令,具有较高的效率。在编程时根据实际情况合理选择堆或者栈,可以提高程序的效率与可靠性。
There are five kind of memory allocations in programming with C++: Heap, Stack, Free memory block, Globle/Static variable memory block and Const variable memory block. Heap is allocated by operator 'new', and released by operator 'delete'. It's easy to be realized and has perfect usage of memory. Stack is automatically allocated and released by C++ complier. It has more efficiency using specific push/pop instructions. We should make a reasonable selection between heap and stack by actual circumstance in order to improve efficiency and reliability when programming.
出处
《芜湖职业技术学院学报》
2006年第2期19-20,共2页
Journal of Wuhu Institute of Technology
关键词
内存分区
堆
栈
区分
内存大小
越界
memory allocation
heap
stack
distinction
memory size
overflow