I am new to mac and instruments, I use it to test the my Qt app, I found a lot of leaked objects, almost all of them are coming from Qt lib.I check my codes very careful but can't find the problem. To avoid the problem of memory leak, I strictly obey the rules of RAII, always let class handle the resources, make sure every widget has a parent, those widget without parent(intented) will guard by smart pointer or Qt::WA_DeleteOnClose.
To fix the memory leak warning, I write a very simple Qt app and use it as a test, the instruments always show that I have some memory leaks(as graph) even the most simplest Qt app I created.
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QLabel w;
w.resize(320, 240);
w.show();
return a.exec();
}
The graph of instruments
I alter the codes a little bit, and see the memory leak show by Instruments would keep rising or not.
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
for(size_t i = 0; i != 100; ++i){
QLabel w;
w.resize(320, 240);
w.show();
}
QLabel w;
w.resize(320, 240);
w.show();
return a.exec();
}
The memory leaking do increase, I strongly hope that this is a mistake of the instrument, else I have to drop back to Qt4(and I don't know it would have the same problem or not).I don't think this simple app could pass the quality check of the mac app store(OSX). What is going on?How should I explain this phenomenon?If there are no memory leak, I should not see any message of the leak object, am I correct?A bug of Qt5.0.2?