[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[riena-dev] Losing my reference
|
Hi Rienars,
While strolling through the usages of our ExtensionInjector (as part of
a QA task) I realized that we are producing memory leaks. This happens
every time e.g. when we wire instances (i.e. perform service and/or
extension injection) that have been created from extensions (this
happens automagicaly). These instances do not have a dedicated life
cycle - they do not get disposed or stopped in such a way that the
injectors could take care of that. These instances simply will not be
used when no longer needed and than they will be garbage collected.
Unfortunately this will not happen when they have been wired because the
injectors keep a reference to those instances and the injectors also
register themselves as listeners to the framework (osgi/equinox). This
connection to the framework will only be cut when the injectors get stopped!
To avoid this leaking I have ´renovated´ the injectors. They do no
longer keep a strong reference to their ´targets´ - they use now a
WeakRef which is a utility class that uses internally a WeakReference to
track the reference to the ´targets´. When such a reference is about to
be reclaimed by the garbage collector the WekRef's notification callback
method is called and .. drum roll .. the injector will be stopped.
Since this is very delicate stuff - please watch out for weird or
unexpected behavior in Riena. ;-)
Tschüß,
Stefan
-------------------------------------------------------------
compeople AG
Untermainanlage 8
60329 Frankfurt/Main
fon: 069 / 27 22 18 0
fax: 069 / 27 22 18 22
web: www.compeople.de
Vorstand: Jürgen Wiesmaier
Aufsichtsratsvorsitzender: Christian Glanz
Sitz der Gesellschaft: Frankfurt/Main
Handelsregister Frankfurt HRB 56759
Ust-Ident.-Nr: DE207665352
-------------------------------------------------------------