<bdo id='WIkaP'></bdo><ul id='WIkaP'></ul>
  • <tfoot id='WIkaP'></tfoot>

        <legend id='WIkaP'><style id='WIkaP'><dir id='WIkaP'><q id='WIkaP'></q></dir></style></legend>
      1. <i id='WIkaP'><tr id='WIkaP'><dt id='WIkaP'><q id='WIkaP'><span id='WIkaP'><b id='WIkaP'><form id='WIkaP'><ins id='WIkaP'></ins><ul id='WIkaP'></ul><sub id='WIkaP'></sub></form><legend id='WIkaP'></legend><bdo id='WIkaP'><pre id='WIkaP'><center id='WIkaP'></center></pre></bdo></b><th id='WIkaP'></th></span></q></dt></tr></i><div id='WIkaP'><tfoot id='WIkaP'></tfoot><dl id='WIkaP'><fieldset id='WIkaP'></fieldset></dl></div>

      2. <small id='WIkaP'></small><noframes id='WIkaP'>

        C++,自由存储 vs 堆

        C++, Free-Store vs Heap(C++,自由存储 vs 堆)
        <i id='aSvbr'><tr id='aSvbr'><dt id='aSvbr'><q id='aSvbr'><span id='aSvbr'><b id='aSvbr'><form id='aSvbr'><ins id='aSvbr'></ins><ul id='aSvbr'></ul><sub id='aSvbr'></sub></form><legend id='aSvbr'></legend><bdo id='aSvbr'><pre id='aSvbr'><center id='aSvbr'></center></pre></bdo></b><th id='aSvbr'></th></span></q></dt></tr></i><div id='aSvbr'><tfoot id='aSvbr'></tfoot><dl id='aSvbr'><fieldset id='aSvbr'></fieldset></dl></div>
        <legend id='aSvbr'><style id='aSvbr'><dir id='aSvbr'><q id='aSvbr'></q></dir></style></legend>

              <bdo id='aSvbr'></bdo><ul id='aSvbr'></ul>

              <small id='aSvbr'></small><noframes id='aSvbr'>

              <tfoot id='aSvbr'></tfoot>

                  <tbody id='aSvbr'></tbody>
                  本文介绍了C++,自由存储 vs 堆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 new/delete 进行动态分配据说发生在 free-store 上,
                  malloc/free 操作使用.

                  我想知道在实践中是否存在实际差异.
                  编译器会区分这两个术语吗?(免费存储,而不是new/malloc)

                  Dynamic allocations with new/delete are said to take place on the free-store,
                  while malloc/free operations use the heap.

                  I'd like to know if there is an actual difference, in practice.
                  Do compilers make a distinction between the two terms? (Free store and Heap, not new/malloc)

                  推荐答案

                  参见 http://www.gotw.ca/gotw/009.htm;它比我能更好地描述堆和自由存储之间的差异:

                  See http://www.gotw.ca/gotw/009.htm; it can describe the differences between the heap and the free-store far better than I could:

                  免费商店:

                  免费商店是两者之一动态内存区域,分配/释放通过新建/删除.对象生命周期可以是少于存储时间分配;即自由存储对象可以不分配内存被立即初始化,并且可以在没有记忆的情况下被摧毁立即解除分配.在此期间分配存储的时间但是在对象的生命周期之外,可以访问存储和通过虚空*操纵但没有原型对象的非静态成员或成员函数可能是访问,获取他们的地址,或以其他方式被操纵.

                  The free store is one of the two dynamic memory areas, allocated/freed by new/delete. Object lifetime can be less than the time the storage is allocated; that is, free store objects can have memory allocated without being immediately initialized, and can be destroyed without the memory being immediately deallocated. During the period when the storage is allocated but outside the object's lifetime, the storage may be accessed and manipulated through a void* but none of the proto-object's nonstatic members or member functions may be accessed, have their addresses taken, or be otherwise manipulated.

                  堆:

                  堆是另一个动态内存区域,由 malloc/free 分配/释放以及它们的变种.请注意,同时默认的全局新建和删除可能在以下方面实施malloc 和 free 由特定编译器,堆不一样自由存储和内存分配在一个区域不能安全地解除分配另一个.从分配的内存堆可用于类的对象按放置类型 - 新建和显式销毁.如果这样使用,则关于自由存储对象生命周期的注意事项此处同样适用.

                  The heap is the other dynamic memory area, allocated/freed by malloc/free and their variants. Note that while the default global new and delete might be implemented in terms of malloc and free by a particular compiler, the heap is not the same as free store and memory allocated in one area cannot be safely deallocated in the other. Memory allocated from the heap can be used for objects of class type by placement-new construction and explicit destruction. If so used, the notes about free store object lifetime apply similarly here.

                  这篇关于C++,自由存储 vs 堆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to limit the number of running instances in C++(C++中如何限制运行实例的数量)
                  Using boost::asio::async_read with stdin?(将 boost::asio::async_read 与 stdin 一起使用?)
                  How to find out what dependencies (i.e other Boost libraries) a particular Boost library requires?(如何找出特定 Boost 库需要哪些依赖项(即其他 Boost 库)?)
                  What#39;s the purpose of a leading quot;::quot; in a C++ method call(引导“::的目的是什么?在 C++ 方法调用中)
                  Boost Spirit x3: parse into structs(Boost Spirit x3:解析为结构体)
                  How boost auto-linking makes choice?(boost自动链接如何做出选择?)
                  1. <legend id='VwPWL'><style id='VwPWL'><dir id='VwPWL'><q id='VwPWL'></q></dir></style></legend>
                    <i id='VwPWL'><tr id='VwPWL'><dt id='VwPWL'><q id='VwPWL'><span id='VwPWL'><b id='VwPWL'><form id='VwPWL'><ins id='VwPWL'></ins><ul id='VwPWL'></ul><sub id='VwPWL'></sub></form><legend id='VwPWL'></legend><bdo id='VwPWL'><pre id='VwPWL'><center id='VwPWL'></center></pre></bdo></b><th id='VwPWL'></th></span></q></dt></tr></i><div id='VwPWL'><tfoot id='VwPWL'></tfoot><dl id='VwPWL'><fieldset id='VwPWL'></fieldset></dl></div>

                        <tfoot id='VwPWL'></tfoot>

                        1. <small id='VwPWL'></small><noframes id='VwPWL'>

                            <bdo id='VwPWL'></bdo><ul id='VwPWL'></ul>
                              <tbody id='VwPWL'></tbody>