我有一个简单的代码:
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
return 0;
}
我使用 pro 文件在 Qt Creator 中编译它:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = testLeaks
TEMPLATE = app
SOURCES += main.cpp
HEADERS +=
FORMS +=
命令valgrind ./testLeaks
说有关泄漏并打印以下内容:
==31276== HEAP SUMMARY:
==31276== in use at exit: 1,190,544 bytes in 7,267 blocks
==31276== total heap usage: 46,096 allocs, 38,829 frees, 6,716,079 bytes allocated
==31276==
==31276== LEAK SUMMARY:
==31276== definitely lost: 2,788 bytes in 11 blocks
==31276== indirectly lost: 7,065 bytes in 182 blocks
==31276== possibly lost: 318,238 bytes in 1,233 blocks
==31276== still reachable: 862,453 bytes in 5,841 blocks
==31276== suppressed: 0 bytes in 0 blocks
如果我评论 QApplication,则没有泄漏。为什么这个类会泄漏?