Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [Common Navigator] possible memory problems w/ NavigatorContentDescriptorManager
[Common Navigator] possible memory problems w/ NavigatorContentDescriptorManager [message #334014] Thu, 15 January 2009 20:11 Go to next message
Tracy Hodges is currently offline Tracy HodgesFriend
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 messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
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


Re: [Common Navigator] possible memory problems w/ NavigatorContentDescriptorManager [message #334043 is a reply to message #334017] Fri, 16 January 2009 14:23 Go to previous message
Tracy Hodges is currently offline Tracy HodgesFriend
Messages: 2
Registered: July 2009
Junior Member
I still have not entirely convinced myself that there is not something
wrong with my code. But if I can find some time, I will attempt to put
together a simplier test program to demonstrate this and file the bugs if
I can get one.
Previous Topic:Rearrange dropins folder fails
Next Topic:Where to write initialization code before plug-in launches?
Goto Forum:
  


Current Time: Sat Nov 02 18:05:19 GMT 2024

Powered by FUDForum. Page generated in 0.03501 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top