我正在尝试使用Qt / C ++调试大型应用程序构建,并且valgrind报告了来自内部Qt东西的大量内存泄漏。
谁能为Qt应用程序共享适当的valgrind抑制文件?

谢谢 !

例如。

#include <qobject.h>
int main()
{
  QObject o;
  return 0;
}


返回:

$ valgrind --leak-check = full --show-reachable =是./leak
== 12655 == Memcheck,内存错误检测器
== 12655 ==朱利安·塞沃德(Julian Seward)等人版权所有(C)2002-2009和GNU GPL。
== 12655 ==使用Valgrind-3.5.0-Debian和LibVEX;使用-h重新运行以获取版权信息
== 12655 ==命令:./ leak
== 12655 ==
== 12655 ==
== 12655 ==堆摘要:
== 12655 ==在出口使用:7块中的744字节
== 12655 ==总堆使用量:28个分配,21个释放,1,640个字节分配
== 12655 ==
== 12655 ==在7的丢失记录1中仍然可以访问1块中的16个字节
== 12655 == at 0x4C229C7:运算符new(unsigned long)(vg_replace_malloc.c:220)
== 12655 ==通过0x6203124:QThreadData :: current()(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x62FC4BC:QObject :: QObject(QObject *)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x4008D2:main(在/ tmp / Qt / bin / leak中)
== 12655 ==
== 12655 ==丢失记录2之7中仍可以访问1块中的96字节
== 12655 == at 0x4C229C7:运算符new(unsigned long)(vg_replace_malloc.c:220)
== 12655 ==通过0x62030FC:QThreadData :: current()(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x62FC4BC:QObject :: QObject(QObject *)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x4008D2:main(在/ tmp / Qt / bin / leak中)
== 12655 ==
== 12655 ==丢失记录3之7中仍然可以访问1块中的96字节
== 12655 == at 0x4C229C7:运算符new(unsigned long)(vg_replace_malloc.c:220)
== 12655 ==通过0x62041CD:QWaitCondition :: QWaitCondition()(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x6200EAF:??? (在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x62010A0:??? (在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x6203132:QThreadData :: current()(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x62FC4BC:QObject :: QObject(QObject *)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x4008D2:main(在/ tmp / Qt / bin / leak中)
== 12655 ==
== 12655 ==丢失记录4之7中仍然可以访问1块中的120个字节
== 12655 == at 0x4C229C7:运算符new(unsigned long)(vg_replace_malloc.c:220)
== 12655 ==通过0x61FE681:QMutex :: QMutex(QMutex :: RecursionMode)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x6200DC8:QThreadData :: QThreadData(int)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x620310C:QThreadData :: current()(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x62FC4BC:QObject :: QObject(QObject *)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x4008D2:main(在/ tmp / Qt / bin / leak中)
== 12655 ==
== 12655 ==丢失记录5之7中仍然可以访问1块中的120个字节
== 12655 == at 0x4C229C7:运算符new(unsigned long)(vg_replace_malloc.c:220)
== 12655 ==通过0x61FE681:QMutex :: QMutex(QMutex :: RecursionMode)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x6200DE9:QThreadData :: QThreadData(int)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x620310C:QThreadData :: current()(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x62FC4BC:QObject :: QObject(QObject *)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x4008D2:main(在/ tmp / Qt / bin / leak中)
== 12655 ==
== 12655 ==丢失记录6之7中仍可访问1块中的120个字节
== 12655 == at 0x4C229C7:运算符new(unsigned long)(vg_replace_malloc.c:220)
== 12655 ==通过0x61FE681:QMutex :: QMutex(QMutex :: RecursionMode)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x6200E77:??? (在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x62010A0:??? (在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x6203132:QThreadData :: current()(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x62FC4BC:QObject :: QObject(QObject *)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x4008D2:main(在/ tmp / Qt / bin / leak中)
== 12655 ==
== 12655 == 1块中的176个字节在丢失记录7 of 7中仍可访问
== 12655 == at 0x4C229C7:运算符new(unsigned long)(vg_replace_malloc.c:220)
== 12655 ==通过0x6201092:??? (在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x6203132:QThreadData :: current()(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x62FC4BC:QObject :: QObject(QObject *)(在/usr/lib/libQtCore.so.4.5.2中)
== 12655 ==通过0x4008D2:main(在/ tmp / Qt / bin / leak中)
== 12655 ==
== 12655 ==泄漏摘要:
== 12655 ==肯定会丢失:0字节(0块)
== 12655 ==间接丢失:0个字节,共0个块
== 12655 ==可能丢失:0字节,共0个块
== 12655 ==仍可到达:7个块中的744个字节
== 12655 ==已抑制:0个字节,共0个块
== 12655 ==
== 12655 ==有关检测到的和抑制的错误的计数,请重新运行:-v
== 12655 ==错误摘要:0个上下文中的0个错误(禁止显示:8个中的8个)

最佳答案

--show-reachable显示实际上没有泄漏的内存,即使valgrind称它为丢失记录。您的测试应用程序不会泄漏任何内存。

对于这种特殊情况,您不需要任何valgrind抑制。对于其他人,也许可以,但是您应该使用valgrind的--gen-suppressions选项为您生成这些抑制。

09-11 19:17