| Item Providers causing memory Leak? [message #676932] |
Mon, 06 June 2011 22:22  |
Samantha Chan Messages: 60 Registered: July 2009 |
Member |
|
|
Hi,
I have created a table view based on an EMF model.
In my view, I have a label provider that extends from AbstractFactoryLabelProvider. I have a custom implementation of the content provider that does not extend from AbstractFactoryContentProvider. I passed a ComposedAdapterFactory to the label provider, so eventually it delegates to my model's item provider to retrieve labels and images. I believe this is pretty standard.
My model is updated every 3 seconds. When the model is refreshed, we remove one instance of a model object, and add a new one in. The view is updated correctly to show these changes.
We expect that when the object is removed from our model, the object is no longer referenced by anything and it should be garbage collected.
However, we have noticed that this is not the case, We found that none of the model objects are cleaned up after they are removed. I tracked it down to the item provider for the object. Our item providers are singleton, so we have one item provider for each model type. When the label provider attempts to retrieve label, the AdapterFactoryLabelProvider calls the AdapterFactory to adapt the object to its item provider. Everytime this method gets called, eventually the object's item provider is called to add the "notifier" to a "target" list. - via ItemProviderAdapter.setTarget. However, the object is never removed from the item provider when it is removed from the model. (ItemProviderAdapter.unsetTarget is never called.) As a result, our model objects are never garbage collected, and eventually we run out of memory.
My question is... when are the notifiers supposed to be removed from the ItemProviderAdapter's target list? Is this removal handled automatically when the object is removed from the model (via some notification?) If not, what is the best way of removing these references?
Thanks for your help.
Samantha
|
|
|