热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

堆和免费商店有什么区别?[重复]-Whatisthedifferencebetweentheheapandthefreestore?[duplicate]

Thisquestionalreadyhasananswerhere:这个问题在这里已有答案:C++,Free-StorevsHeap7answers

This question already has an answer here:

这个问题在这里已有答案:

  • C++, Free-Store vs Heap 7 answers
  • C ++,Free-Store vs Heap 7答案

Originally a pedantics war on @Als answer here, it also sparked a discussion in the C++ chatroom.

最初对@Als的一场迂腐战争在这里回答,它也引发了C ++聊天室的讨论。

This article by Herb Sutter distinguishes between the two, but is also over a decade old, as it clearly was written before 2000 and also talks about the standard draft, which can only mean C++98 draft. Though, I still expect Herb, as part of the committee, to be knowledgeable about this stuff.

Herb Sutter的这篇文章区分了两者,但也有十多年的历史,因为它显然是在2000年之前编写的,并且还讨论了标准草案,它只能代表C ++ 98草案。尽管如此,作为委员会成员,我仍然希望Herb能够了解这些东西。

I know of this and this question/answer, but the second just cites Herb's article while the first cites another source that simply rejects the use of the term "heap", aka they are both not exactly satisfactory. Also, I can't find any free-store or freestore tag on SO (until this question, I created the former one now).

我知道这个和这个问题/答案,但第二个引用了Herb的文章,而第一个引用了另一个简单地拒绝使用术语“堆”的来源,也就是说它们都不完全令人满意。另外,我在SO上找不到任何免费商店或freestore标签(直到这个问题,我现在创建了前一个)。

Now, what is really the difference, if any?

现在,真的有什么区别,如果有的话?

3 个解决方案

#1


21  

Well, the current C++ standard only uses the term "free store" - the only use of "heap" in the Standard is to describe the heap data structure in the Standard Library. So "heap" is not a very useful term to use when trying to discuss C++ problems accurately, though of course everyone does it.

那么,当前的C ++标准只使用术语“免费存储” - 标准中唯一使用“堆”的是描述标准库中的堆数据结构。所以“堆”在尝试准确地讨论C ++问题时并不是一个非常有用的术语,当然每个人都这样做。

#2


14  

In Herb's book "Exceptional C++", he defines:

在Herb的书“Exceptional C ++”中,他定义:

Heap: A dynamic memory area that is allocated/freed by the malloc/free functions.

堆:由malloc / free函数分配/释放的动态内存区域。

Free Store: A dynamic memory area that is allocated/freed by new/delete.

自由存储:由新/删除分配/释放的动态内存区域。

Its possible for new and delete to be implemented in terms of malloc and free, so technically, they could be the same memory area. However, as the standard doesn't specify this, its best to treat them separatly, and not to mix malloc/delete or new/free.

它可以用malloc和free实现new和delete,所以从技术上讲,它们可以是相同的内存区域。但是,由于标准没有指定这一点,最好分开处理它们,而不是混合malloc / delete或new / free。

#3


6  

The free-store technically isn't the heap, just as local variables technically aren't on the stack. However, it's extremely rare in my experience to find anybody who won't accept those terms.

从技术上讲,免费存储不是堆,就像技术上局部变量不在堆栈中一样。但是,根据我的经验,找到任何不接受这些条款的人是极其罕见的。


推荐阅读
  • Apple iPad:过渡设备还是平板电脑?
    I’vebeenagonizingoverwhethertopostaniPadarticle.Applecertainlydon’tneedmorepublicityandthe ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • 本文讨论了使用差分约束系统求解House Man跳跃问题的思路与方法。给定一组不同高度,要求从最低点跳跃到最高点,每次跳跃的距离不超过D,并且不能改变给定的顺序。通过建立差分约束系统,将问题转化为图的建立和查询距离的问题。文章详细介绍了建立约束条件的方法,并使用SPFA算法判环并输出结果。同时还讨论了建边方向和跳跃顺序的关系。 ... [详细]
  • IjustinheritedsomewebpageswhichusesMooTools.IneverusedMooTools.NowIneedtoaddsomef ... [详细]
  • This article discusses the efficiency of using char str[] and char *str and whether there is any reason to prefer one over the other. It explains the difference between the two and provides an example to illustrate their usage. ... [详细]
  • Whatsthedifferencebetweento_aandto_ary?to_a和to_ary有什么区别? ... [详细]
  • 本文介绍了Python语言程序设计中文件和数据格式化的操作,包括使用np.savetext保存文本文件,对文本文件和二进制文件进行统一的操作步骤,以及使用Numpy模块进行数据可视化编程的指南。同时还提供了一些关于Python的测试题。 ... [详细]
  • 本文介绍了利用ARMA模型对平稳非白噪声序列进行建模的步骤及代码实现。首先对观察值序列进行样本自相关系数和样本偏自相关系数的计算,然后根据这些系数的性质选择适当的ARMA模型进行拟合,并估计模型中的位置参数。接着进行模型的有效性检验,如果不通过则重新选择模型再拟合,如果通过则进行模型优化。最后利用拟合模型预测序列的未来走势。文章还介绍了绘制时序图、平稳性检验、白噪声检验、确定ARMA阶数和预测未来走势的代码实现。 ... [详细]
  • Introduction(简介)Forbeingapowerfulobject-orientedprogramminglanguage,Cisuseda ... [详细]
  • 本博文基于《Amalgamationofproteinsequence,structureandtextualinformationforimprovingprote ... [详细]
  • [转载]从零开始学习OpenGL ES之四 – 光效
    继续我们的iPhoneOpenGLES之旅,我们将讨论光效。目前,我们没有加入任何光效。幸运的是,OpenGL在没有设置光效的情况下仍然可 ... [详细]
  • C++ OpenCV实战之标记点检测的实现
    C++ OpenCV实战之标记点检测的实现-在实际应用中,能够直接利用霍夫圆检测这些理想方法的应用场景是非常少的,更多的是利用拟合的办法去寻找圆形。大致思路如下,首先先选择要处理的 ... [详细]
  • PriorityQueue源码分析
     publicbooleanhasNext(){returncursor<size||(forgetMeNot!null&am ... [详细]
author-avatar
gaoming1010_143
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有