[Qt-jambi-interest] Memory Leaks - any updates?
Gunnar Sletta
gunnar at trolltech.com
Fri Nov 28 10:41:34 CET 2008
Curt Nowak wrote:
> Hi Gunnar,
>
> thanks for you detailed explanation. You saw it coming: I'm having
> follow-up questions.
I did, actuall ;)
> 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?
Hm... Before I entered this into our task tracker I played a bit with
the code, and I entered my modifierd version into the task tracker as it
still reproduced the problem but contained a lot of debug info, among
them the inner class.
The problem is still the same though, just with a few levels of
indirection.
When you do
button.clicked.connect(this, "create()");
you create a reference from the signal to back to the toplevel and you
have a circular reference that is inpenetrable for the garbage collector.
This is in fact a huge problem, and hopefully we can minimize some of
the impact using weak java references in connections, but that will
introduce regressions in cases where references to the target objects
are not being kept.
Given this happens with all connections, it seems that one must
explicitly dispose all toplevels.
best regards,
Gunnar
More information about the Qt-jambi-interest
mailing list