惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed

博客园 - hong

VBA命令按钮操作 - hong - 博客园 VBA访问word菜单 - hong - 博客园 RUP核心概念解析 RUP 核心概念 IBM Rational 技术文档下载 项目管理规范-RUP管理实施 感叹人生 遗憾 C#中的类型相等与恒等(Equality & Identity) Windows Vista workshop 理解抽象类和接口 线程概念 开始找工作了 BI理解 Web Service基础 改变人的一生的五句话 在web页面中显示多页的tif文件 sql日期转换问题 Visual Studio Team System资源
堆和栈的区别
hong · 2006-09-05 · via 博客园 - hong

一般认为在c中分为这几个存储区 

1栈 - 有编译器自动分配释放 
2堆 - 一般由程序员分配释放,若程序员不释放,程序结束时可能由OS回收 
3全局区(静态区),全局变量和静态变量的存储是放在一块的,初始化的全局变量和静态变量在一块 
区域,未初始化的全局变量和未初始化的静态变量在相邻的另一块区域。 
- 程序结束释放 
4另外还有一个专门放常量的地方。 - 程序结束释放 

区别:
2、栈的空间大小有限定,vc的缺省是2M,堆的空间大小是没有限定的
3、栈有系统管理,堆有程序员管理,所以堆用不好会发生内存泄漏
4、频繁的new和free,堆上会产生内存碎片,栈不会
5、栈比在堆上存取数据快些,栈更快速高效,
6、栈是有系统支持的,而堆是有函数库提供的
7、只有少数数据类型列入int、float等会在栈上分配,大多数用户类型都在堆上。
8、栈是系统数据结构,对于进程/线程是唯一的;堆是函数库内部数据结构,不一定唯一