Skip to content
New issue

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

五星 C++ 堆和栈的区别 | Nature 的博客 #9

Open
NatureLan-sudo opened this issue Sep 2, 2022 · 0 comments
Open

五星 C++ 堆和栈的区别 | Nature 的博客 #9

NatureLan-sudo opened this issue Sep 2, 2022 · 0 comments

Comments

@NatureLan-sudo
Copy link
Owner

https://naturelan-sudo.github.io/2022/09/02/%E4%BA%94%E6%98%9F%20C++%E6%A0%88%E5%92%8C%E5%A0%86%E7%9A%84%E5%8C%BA%E5%88%AB%20%20%20-%20%20%20%202022-08-29/#more

申请方式: 栈是系统自动分配,堆是程序员主动申请。申请后系统响应:分配栈空间,如果剩余空间大于申请空间则分配成功,否则分配失败栈溢出;申请堆空间,堆在内存中呈现的方式类似于链表(记录空闲地址空间的链表),在链表上寻找第一个大于申请空间的节点分配给程序,将该节点从链表中删除,大多数系统中该块空间的首地址存放的是本次分配空间的大小,便于释放,将该块空间上的剩余空间再次连接在空闲链表上。栈在内存中是连续

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant