<tfoot id='YgiSo'></tfoot>

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

        内存泄漏是“未定义的行为"吗?C++中的类问题?

        时间:2023-07-19
        • <bdo id='iwNJU'></bdo><ul id='iwNJU'></ul>

              • <i id='iwNJU'><tr id='iwNJU'><dt id='iwNJU'><q id='iwNJU'><span id='iwNJU'><b id='iwNJU'><form id='iwNJU'><ins id='iwNJU'></ins><ul id='iwNJU'></ul><sub id='iwNJU'></sub></form><legend id='iwNJU'></legend><bdo id='iwNJU'><pre id='iwNJU'><center id='iwNJU'></center></pre></bdo></b><th id='iwNJU'></th></span></q></dt></tr></i><div id='iwNJU'><tfoot id='iwNJU'></tfoot><dl id='iwNJU'><fieldset id='iwNJU'></fieldset></dl></div>
                <legend id='iwNJU'><style id='iwNJU'><dir id='iwNJU'><q id='iwNJU'></q></dir></style></legend><tfoot id='iwNJU'></tfoot>
              • <small id='iwNJU'></small><noframes id='iwNJU'>

                    <tbody id='iwNJU'></tbody>
                  本文介绍了内存泄漏是“未定义的行为"吗?C++中的类问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  事实证明,在 C++ 中,许多看起来很无辜的东西是未定义的行为.例如,一旦一个非空指针被delete甚至打印出该指针值是未定义的行为.

                  Turns out many innocently looking things are undefined behavior in C++. For example, once a non-null pointer has been delete'd even printing out that pointer value is undefined behavior.

                  现在内存泄漏肯定很糟糕.但它们是什么阶级情况——定义的、未定义的或其他什么类别的行为?

                  Now memory leaks are definitely bad. But what class situation are they - defined, undefined or what other class of behavior?

                  推荐答案

                  内存泄漏.

                  没有未定义的行为.泄漏内存是完全合法的.

                  Memory leaks.

                  There is no undefined behavior. It is perfectly legal to leak memory.

                  未定义行为:是标准特别不想定义的操作,由实现决定,以便在不违反标准的情况下灵活地执行某些类型的优化.

                  Undefined behavior: is actions the standard specifically does not want to define and leaves upto the implementation so that it is flexible to perform certain types of optimizations without breaking the standard.

                  内存管理定义明确.
                  如果您动态分配内存并且不释放它.然后,内存仍然是应用程序的属性,可以按照它认为合适的方式进行管理.您丢失了对那部分内存的所有引用这一事实既不存在也不存在.

                  Memory management is well defined.
                  If you dynamically allocate memory and don't release it. Then the memory remains the property of the application to manage as it sees fit. The fact that you have lost all references to that portion of memory is neither here nor there.

                  当然,如果您继续泄漏,那么您最终将耗尽可用内存并且应用程序将开始抛出 bad_alloc 异常.但这是另一个问题.

                  Of course if you continue to leak then you will eventually run out of available memory and the application will start to throw bad_alloc exceptions. But that is another issue.

                  这篇关于内存泄漏是“未定义的行为"吗?C++中的类问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在C++中获取Windows下的内存使用情况 下一篇:如何获取使用 malloc() 分配的内存块的大小?

                  相关文章

                  <i id='XkzYe'><tr id='XkzYe'><dt id='XkzYe'><q id='XkzYe'><span id='XkzYe'><b id='XkzYe'><form id='XkzYe'><ins id='XkzYe'></ins><ul id='XkzYe'></ul><sub id='XkzYe'></sub></form><legend id='XkzYe'></legend><bdo id='XkzYe'><pre id='XkzYe'><center id='XkzYe'></center></pre></bdo></b><th id='XkzYe'></th></span></q></dt></tr></i><div id='XkzYe'><tfoot id='XkzYe'></tfoot><dl id='XkzYe'><fieldset id='XkzYe'></fieldset></dl></div>
                  • <bdo id='XkzYe'></bdo><ul id='XkzYe'></ul>
                • <small id='XkzYe'></small><noframes id='XkzYe'>

                  <legend id='XkzYe'><style id='XkzYe'><dir id='XkzYe'><q id='XkzYe'></q></dir></style></legend>

                    <tfoot id='XkzYe'></tfoot>