以下代码使用Qt SQL版本4.9和sqlite。
#include <QtSql>
int main(int argc, const char **argv) {
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("db.sqlite");
db.open();
QSqlQuery query;
query.exec("CREATE TABLE test (test VARCHAR PRIMARY KEY);");
db.close();
}
Valgrind给我一个这样的泄漏报告:
==2832== LEAK SUMMARY:
==2832== definitely lost: 168 bytes in 3 blocks
==2832== indirectly lost: 556 bytes in 9 blocks
==2832== possibly lost: 0 bytes in 0 blocks
==2832== still reachable: 51,660 bytes in 83 blocks
这只是一个简单的SQL查询,我不明白为什么会有这么多泄漏。这些泄漏位于QLibrary和QFactoryLoader中。有没有办法在应用程序退出时清理内存?