[Qt-jambi-interest] disposing items

Eskil Abrahamsen Blomfeldt eblomfel at trolltech.com
Fri Aug 14 11:05:27 CEST 2009


Aekold Helbrass wrote:
> I noticed that there is dispose() method in QJambiObject. Tell me
> please how can I determine should I use it or not? In Swing there were
> no need to dispose items, you can just remove it from component tree
> and it will be collected by GC. But what about Jambi objects? For
> example I am keeping QFontMetrics instance, and I change it with font
> change. Should I dispose old QFontMetrics before reassigning it?
>
>   
Hi,

The dispose() method was mainly introduced to allow more fine-grained 
memory management, presenting developers with the opportunity to 
minimize the impact of garbage collection in critical parts of the code.

All objects in Qt Jambi will be garbage collected when they are no 
longer referenced. However, because of a bug which in some cases can 
cause memory leaks, we recommend that people manually dispose their top 
level widgets when they are no longer needed. This is also the procedure 
taken by Swing. Other than that, there is no reason to worry about the 
dispose() method unless you have large objects in memory and want to 
ensure that the memory is released.

-- Eskil







More information about the Qt-jambi-interest mailing list