G++ Multi-platform memory leak detection tool

后端 未结 6 588
不思量自难忘°
不思量自难忘° 2021-02-05 20:58

Does anyone know where I can find a memory memory leak detection tool for C++ which can be either run in a command line or as an Eclipse plug-in in Windows and Linux. I would l

6条回答
  •  面向向阳花
    2021-02-05 21:18

    DUMA is a cross-platform leak detection library which I use for many of my projects. It's nice because you don't have to #include any DUMA-specific header, but just link in the library before you link in your system's libc, which contains the memory allocation routines, and after linking in libstdc++.

    It can be kind of tricky to set up, especially when used with C++ projects, but I think that it is well worth the time invested. It has helped me to find a few memory leaks before that I might not have discovered otherwise, and one case where I deleted an allocation twice.

    One note: it's much easier if you build a static archive (built by default on Windows) because it helps to reduce "false positives" that are actually caused by leaky runtimes.

提交回复
热议问题