<tfoot id='jQCxQ'></tfoot>

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

    2. <legend id='jQCxQ'><style id='jQCxQ'><dir id='jQCxQ'><q id='jQCxQ'></q></dir></style></legend>

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

    3. GCC 内存泄漏检测相当于 Microsoft crtdbg.h?

      GCC memory leak detection equivalent to Microsoft crtdbg.h?(GCC 内存泄漏检测相当于 Microsoft crtdbg.h?)

      1. <tfoot id='XFoYd'></tfoot>
            <bdo id='XFoYd'></bdo><ul id='XFoYd'></ul>

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

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

                <tbody id='XFoYd'></tbody>
              <legend id='XFoYd'><style id='XFoYd'><dir id='XFoYd'><q id='XFoYd'></q></dir></style></legend>

                本文介绍了GCC 内存泄漏检测相当于 Microsoft crtdbg.h?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 Visual Studio 中使用 Microsoft MSVC 编译器开发通用 C++ 库多年后,我们现在将其移植到 Linux/Mac OS X(为我们祈祷).我已经习惯并非常喜欢 MSVC 中简单的内存泄漏检测机制:

                After many years of working on a general-purpose C++ library using the Microsoft MSVC compiler in Visual Studio, we are now porting it to Linux/Mac OS X (pray for us). I have become accustomed and quite fond of the simple memory leak detection mechanism in MSVC:

                #ifdef DEBUG
                    #define _CRTDBG_MAP_ALLOC
                    #define NEW   new( _NORMAL_BLOCK, __FILE__, __LINE__)
                    #include <stdlib.h>
                    #include <crtdbg.h>
                #else
                    #define NEW   new
                #endif
                

                每次内存分配都是使用这个新宏完成的.每当使用我们库的进程终止时,任何内存泄漏(尚未解除分配的块)都会与文件和最初分配内存的行 # 一起报告在控制台上.

                Every memory allocation is done using this NEW macro. Whenever a process using our library terminates, any memory leaks (blocks that have not been de-allocated) are reported on the console along with the file and line # where the memory was originally allocated.

                我喜欢的部分是我不必主动使用性能工具运行"或以其他方式表明我正在寻找泄漏.在常规开发过程中,每次进程终止时都会向我报告泄漏.

                The part about this that I like is that I don't have to actively "run with performance tool" or otherwise indicate that I am looking for leaks. Leaks are reported to me in the regular course of development, every time a process terminates.

                现在我们正在转向 GCC 世界,我发现内存泄漏检测工具(其中许多非常复杂)要求我明确指出我处于泄漏搜寻模式.我的 IDE 是 Xcode,我已经研究了一些分配/泄漏检测工具(如 Instruments 和 MallocDebug),但我承认我还没有花时间完全了解它们.我一直被这样一个事实拖延,因为我实际上必须提前指明我正在寻找泄漏,而不是自动收到警报.

                Now that we are moving to the GCC world, I find that the memory leak detection tools, many of which are quite sophisticated, require that I explicitly indicate that I'm in leak hunting mode. My IDE is Xcode and I've looked into some of the allocation/leak detection tools (like Instruments and MallocDebug) but I admit I haven't spent the time to get my head around them fully yet. I keep getting put off by the fact that I actually have to specify that I'm looking for a leak ahead of time, instead of being alerted to it automatically.

                我正在使用 Xcode 3.2,我听说现在有一个与静态分析工具的漂亮集成,但我还没有研究过这个.我正在寻找一些关于我的选择的想法.GCC 和/或 Xcode 中是否有类似的机制?是否有一个简单的第三方库或工具可以执行我所了解和喜爱的非常基本的功能?还是我应该接受它并学习新的做事方式?

                I am using Xcode 3.2 and I hear that there's now nifty integration with a static analysis tool, but again I haven't looked into this. I'm looking for some idea of what my options are. Is there a comparable mechanism built into GCC and/or Xcode? Is there a simple third-party library or tool that performs the very basic functionality that I know and love? Or should I suck it up and learn the new way of doing things?

                推荐答案

                你应该看看 "Cross-Platform Memory Leak Detector",看起来与 crtdbg.h 技术非常相似.

                You should have a look at "Cross-Platform Memory Leak Detector", looks very similar to the crtdbg.h technique.

                这篇关于GCC 内存泄漏检测相当于 Microsoft crtdbg.h?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Constructor initialization Vs assignment(构造函数初始化 Vs 赋值)
                Is a `=default` move constructor equivalent to a member-wise move constructor?(`=default` 移动构造函数是否等同于成员移动构造函数?)
                Has the new C++11 member initialization feature at declaration made initialization lists obsolete?(声明时新的 C++11 成员初始化功能是否使初始化列表过时了?)
                Order of constructor call in virtual inheritance(虚继承中构造函数调用的顺序)
                How to use sfinae for selecting constructors?(如何使用 sfinae 选择构造函数?)
                Initializing a union with a non-trivial constructor(使用非平凡的构造函数初始化联合)

                    • <bdo id='4fLMq'></bdo><ul id='4fLMq'></ul>

                      • <tfoot id='4fLMq'></tfoot>

                          <tbody id='4fLMq'></tbody>
                      • <small id='4fLMq'></small><noframes id='4fLMq'>

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