[Common Navigator] possible memory problems w/ NavigatorContentDescriptorManager [message #334014] |
Thu, 15 January 2009 20:11 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Tracy Hodges![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=tracy.hodges%40ca.com) Messages: 2 Registered: July 2009 |
Junior Member |
|
|
I have been spending a while with JProbe trying to fix some memory leaks
in my RCP application. I have cleaned up quite a few, but still plagued
by something that seems to be out of my control.
The NavigatorContentDescriptorManager manages a series of caches. A
couple (cachedTriggerPointEvaluations and
cachedPossibleChildrenEvaluations) seem to be problematic.
From what I can tell, they grow and grow, but never get smaller. I
realize that they contain some SoftReferences and these really only go
away when an OutOfMemory situation might occur. But is it necessary to
keep everything around until there is no memory?
There are a couple of comments/questions I have.
1) It would appear that the following code in
EvaluationCache.getDescriptors is incorrect and in my case always returns
null.
if(toComputeOverrides) {
SoftReference cache = (SoftReference) evaluations.get(anElement);
if( cache != null && (cachedDescriptors = (NavigatorContentDescriptor[])
cache.get()) == null)
evaluations.remove(anElement);
return cachedDescriptors;
}
Within the debugger, I can tell that the method call
'evaluations.get(anElement)' will never find anything and always return
null. The reason it never finds anything is because it is using the
anElement to lookup in the HashMap, but the HashMap keys are
EvalutationReferences to the anElement.
In my case, the 'equals' method on my object (anElement) gets called to
compare with an EvalutationReference that refers to my object. I
temporarily modified my equals method check for java.lang.ref.Reference
and see if it was equal to the object contained within it. When I did
that, the get call above started to work (not return null).
2) Even with my workaround for the problem above, memory continues to
grow. Even when you close the part containing the Common Navigator, the
issue continues. There seems to be nothing in the code to clean up those
caches. Although I have not verified it, it would seem the SoftReference
would continue to grow until the memory was filled up.
If needed, I might be able to create a smaller program to demonstrate
this, but thought I would ask the list first.
|
|
|
Re: [Common Navigator] possible memory problems w/ NavigatorContentDescriptorManager [message #334017 is a reply to message #334014] |
Thu, 15 January 2009 23:28 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Francis Upton IV![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=francisu%40ieee.org) Messages: 472 Registered: July 2009 Location: Oakland, CA |
Senior Member |
|
|
See my answers inline. (though I'm also replying to you personally,
please respond to the news group, and please include links to the bug
reports that you file for posterity).
Francis
Tracy Hodges wrote:
> I have been spending a while with JProbe trying to fix some memory leaks
> in my RCP application. I have cleaned up quite a few, but still plagued
> by something that seems to be out of my control.
>
> The NavigatorContentDescriptorManager manages a series of caches. A
> couple (cachedTriggerPointEvaluations and
> cachedPossibleChildrenEvaluations) seem to be problematic.
> From what I can tell, they grow and grow, but never get smaller. I
> realize that they contain some SoftReferences and these really only go
> away when an OutOfMemory situation might occur. But is it necessary to
> keep everything around until there is no memory?
This the the way you are supposed to cache things in Java. The
alternative is a WeakReference, but those are much more aggressively
garbage collected.
>
> There are a couple of comments/questions I have.
>
> 1) It would appear that the following code in
> EvaluationCache.getDescriptors is incorrect and in my case always
> returns null.
>
> if(toComputeOverrides) {
> SoftReference cache = (SoftReference) evaluations.get(anElement);
> if( cache != null && (cachedDescriptors =
> (NavigatorContentDescriptor[]) cache.get()) == null)
> evaluations.remove(anElement);
> return cachedDescriptors;
> }
>
> Within the debugger, I can tell that the method call
> 'evaluations.get(anElement)' will never find anything and always return
> null. The reason it never finds anything is because it is using the
> anElement to lookup in the HashMap, but the HashMap keys are
> EvalutationReferences to the anElement.
>
> In my case, the 'equals' method on my object (anElement) gets called to
> compare with an EvalutationReference that refers to my object. I
> temporarily modified my equals method check for java.lang.ref.Reference
> and see if it was equal to the object contained within it. When I did
> that, the get call above started to work (not return null).
Looks like a bug, please file a bug report about this. File to Eclipse
Platform UI.
> 2) Even with my workaround for the problem above, memory continues to
> grow. Even when you close the part containing the Common Navigator, the
> issue continues. There seems to be nothing in the code to clean up
> those caches. Although I have not verified it, it would seem the
> SoftReference would continue to grow until the memory was filled up.
>
> If needed, I might be able to create a smaller program to demonstrate
> this, but thought I would ask the list first.
>
File a different bug about this; I'm not sure if the caches are cleaned
up with the CommonNavigator instances go away, or if they are global.
But it might be a problem. It may be that it's fine the way it is, and
as I mentioned above, the SortReferences can go until memory fills up.
>
>
A small test program for this purposes would be helpful to help me
analyze these problems. You can attach it to one of the bug reports.
Or better still (if you are up to it), make a patch that integrates it
into the CNF test suite.
Thanks for your work and investigation into this.
Francis
--
Common Navigator Framework section in Platform Plugin Developer Guide
(Programmer's Guide)
http://help.eclipse.org/ganymede/topic/org.eclipse.platform. doc.isv/guide/cnf.htm
http://dev.eclipse.org/blogs/francis
http://wiki.eclipse.org/Common_Navigator_Framework
http://wiki.eclipse.org/Common_Navigator_Framework_Use_Cases
You have brains in your head.
You have feet in your shoes.
- Dr Seuss, Oh the Places You'll Go
Platform UI Committer for Common Navigator
http://wiki.eclipse.org/index.php/Common_Navigator_Framework
http://help.eclipse.org/galileo/topic/org.eclipse.platform.d oc.isv/guide/cnf.htm
|
|
|
|
Powered by
FUDForum. Page generated in 0.03064 seconds