[Qt-jambi-interest] Memory Leaks - any updates?
Curt Nowak
cnowak at bwl.uni-hildesheim.de
Thu Nov 27 17:07:41 CET 2008
Hi Gunnar,
thanks for you detailed explanation. You saw it coming: I'm having follow-up questions.
It looks as though you are not referring to my code. You see, my example code (mail sent October 8th) did not contain inner classes. It was all about creating a lot of top-level widgets at runtime. Those widgets do not seem to get gc-ed. Invoking dispose() on each of them does make a big difference but leaves a small memory leak nevertheless. How come?
Cheers, Curt
________________________________
Von: Gunnar Sletta [mailto:gunnar at trolltech.com]
Gesendet: Do 27.11.2008 16:36
An: Curt Nowak
Cc: qt-jambi-interest at trolltech.com
Betreff: Re: [Qt-jambi-interest] Memory Leaks - any updates?
Hi Curt,
<snip>
Now.. back to the real problem... The code was
QWidget window = new QWidget();
QPushButton button = new QPushButton(window) {
public void disposed() {
// something...
}
}
<snip>
By adding debugging data to your application to track a problem, you
incidentally created the problem.
Because of the rather common use of anonymous inner classes in Java, I
think I will have to rephrase my previous statements about memory
management and claim that all top level widgets should be explicitly
disposed. That will solve the problem because that will delete both the
C++ widget and the C++ button, releasing the JNI ref and thus leaving
the Java parts of the objects free for grabs by the GC.
I'll also add this to the documentation.
best regards,
Gunnar
More information about the Qt-jambi-interest
mailing list