We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stack
heap
OS
区别和联系:
c
malloc
p1 = (char *)malloc(10)
int b
b
delete
Windows
overflow
new
通俗易懂的方式来解释堆与栈之间的区别
The text was updated successfully, but these errors were encountered:
No branches or pull requests
堆与栈
stack
): 由编译器自动分配, 存放函数的参数值, 局部变量的值等. 其操作方式类似于数据结构中的栈.heap
): 一般由程序员分配释放, 若程序员不释放, 程序结束时可能由OS
回收. 这里OS
是指: 操作系统(Operating System)区别和联系:
c
语言中的malloc
函数. eg:p1 = (char *)malloc(10)
;int b
; 系统自动在栈中为b
开辟空间;delete
语句才能正确的释放本内存空间. 另外, 由于找到的堆节点的大小不一定正好等于申请的大小, 系统会自动的将多余的那部分重新放入空闲链表中.Windows
下, 栈是向低地址扩展的数据结构, 是一块联系的内存区域. 这句话的意思是栈顶的地址和栈的最大容量是系统预先规定好的, 在Windows
下, 栈的大小是2M(也有人说1M, 总之是一个编译时就确定的常数), 如果申请的空间超过栈的剩余空间, 将提示overflow
. 因此, 能从栈获得的空间较小.new
分配的内存, 一般速度比较慢, 而且容易产生内存碎片, 不过用起来最方便;前方高能
通俗易懂的方式来解释堆与栈之间的区别
overflow
了.The text was updated successfully, but these errors were encountered: