[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] [EMF Databinding] Properly disposing of observables?

Hi,

in one of his enlightening blog posts on the EMF databinding [1] Tom Schindl warned about memory leaks due to observables, which are not disposed when they are no longer needed. He also mentioned:

* ObservableManager, which was added in 3.5. It could be used to keep track of observables in order to dispose them properly. Due to a bug it's currently unusable, but Tom shows a way to fix it for EMFObservables.

* Observables for SWT dispose themselves when the corresponding widget is disposed.

* The rule for all other observables: the one who created it has to dispose it.


As far as I can see, an EObjectObservable listens to the observed EObject only as long as someone listens to the EObjectObservable itself. Once the last listener is removed from the observable, it will also remove its listener from the EObject. This should be enough to avoid listener leaking if you dispose the DataBindingContext, shouldn't it?


I also wonder, if DataBindingContext could be used instead of ObservableManager for life cycle management of observables. It already keeps track of the bindings and thus has a list of all observables which are directly used in those bindings. And you need one anyway. So if you could tell DataBindingContext to also dispose of the observables, you would only have to manually dispose of observables used in computed values. Or am I missing something?

[1] <http://tomsondev.bestsolution.at/2009/06/08/galileo-emf-databinding-%E2%80%93-part-3/> (see "Avoid listener leaking")
--
Andreas