Qt5 QFileDialog is leaking memory?
-
Valgrind is a great tool to check memory leak. It is available under http://valgrind.org/.
This memory leak is not only occur in qt5 but also occurs in versions < qt4.8. One obvious solution to this leak is to user deleteLater on QFileDialog.
Cheers,
-
[quote author="brainTech" date="1357581223"]I have tested it on MacOS 10.7.4 with Qt 4.8.1. While opening QFileDialog several times, memory increases to 200 Mb even 300 MB.[/quote]
Please provide measurements like I did above. To determine whether there is a problem requires more empiric rigour than "open several times". Take my code above and note Virtual, Resident and Shared memory usage of the process at every 10-dialog-mark. Do that until you reach a clear linear trend (either constant (good) or rising (bad)), at least 100 dialog open/close iterations. Maybe all you observed was some standard UI libraries being loaded into virtual memory?
//EDIT: I'm not trying to be harsh or discredit you, I just want clear facts when it comes to serious stuff like memory leaks in such an important part of the library.
-
Hi DerManu,
I forgot to mention that memory leak does not occur when you use static member function of QFileDialog. When you try to use QmessageBox *messageBox = new QMessageBox(); then leak occur. With this, 2-3 MB is increasing.
Real Memory (MB)
125
128
131
135
139
144
.
.
245It keeps on increasing. I have put the measurements from Activity Monitor of MacOS.
I am also new to Qt/QtScript. I was having these issues in the last 2 weeks. I solved this by exec and deleteLater. Is this the right solution? With this solution, memory first increases and then becomes stable at some point but it never comes back to the point from where it started. Can you please put your thoughts on this? Is the behaviour of memory is right?
Regards,