Instruments(famous profile tool on mac) show that a very simple app designed by Qt5.0.2 has memory leak
-
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
!http://i.stack.imgur.com/oW7Hf.png(Call Tree)!
!http://i.stack.imgur.com/frjpP.png(Leaked object)!
I alter the codes a little bit, and see the memory leak show by Instruments would keep rising or not.
@#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(); }@
!http://i.stack.imgur.com/O5dhh.png(Call tree)!
!http://i.stack.imgur.com/aa7su.png(Leaked object)!The memory leak 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).
After a I changed it to infinite loop, not only instruments, but the memory showed by activity monitor also increase steadily(would increase and decrease, but in the long run, it is increasing), no matter private memory or real memory.
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?
-
On Valgrind Qt is known to spawn false positives. I don't know if that is true for Instruments, too.
-
I can't find a data about instruments too, don't know this is a bug or just a false alarm.