This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 233251 - memory leak in java.navigation.ElementNode
Summary: memory leak in java.navigation.ElementNode
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Navigator (show other bugs)
Version: 7.4
Hardware: PC Linux
: P2 normal (vote)
Assignee: Jan Peska
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2013-07-23 13:58 UTC by Petr Cyhelsky
Modified: 2013-08-08 02:30 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Cyhelsky 2013-07-23 13:58:06 UTC
Please take a look at heap dump from:
https://netbeans.org/projects/performance/downloads/download/heapdump_java_navigation.hprof.7z It was taken after all projects were closed and one instance of J2SEProject is still held in memory.
Comment 1 Tomas Zezula 2013-07-23 15:16:53 UTC
Do you see any Java class in the navigator after the project has been closed?
If not neither the VisualizerNode nor the ElementNode should exist otherwise fill an issue on navigator.
Comment 2 Petr Cyhelsky 2013-07-31 13:51:56 UTC
No class can be seen in navigator, because navigator is closed - the current state of the ide can be seen in heapwalker's preview feature on the IDE's frame. Reassigning to navigator as advised.
Comment 3 Jan Peska 2013-08-05 13:54:16 UTC
Well there is no reference in Navigator framework which prevents GC to collect the project (or at least I can't see any). According to the heapdump there is the node reference kept in FixedHeightLayoutCache used in TreeView. I think the problem could be in CSL/Java navigation or in TreeView itself - reassigning back to the Java/Navigation for further evaluation.
Comment 4 Tomas Zezula 2013-08-05 16:46:51 UTC
No problem in CSL/Java navigation - the problem is that the TreeView is holding some Node even the TreeView and the enclosing panel was removed by navigator. It's questionable if it was properly removed as the same problem does not happen in other tree view like projects, files, etc.
Comment 5 Tomas Zezula 2013-08-05 18:56:57 UTC
After the project is closed the BeanTreeView has root context a dummy AbstractNode.
The underlaying TreeView$ExplorerTree's selectionModel (DefaultTreeSelectionModel) is OK as it's empty. However DefaultTreeSelectionModel's rowMapper (FixedHeightLayoutCache) still holds a reference to the last selected node in info.node.

There is no real solution on the Java side except:

((JTree)((MyBeanTreeView)elementView).getComponent()).setSelectionModel(new DefaultTreeSelectionModel());

which will fix just the single instance of BeanTreeView, unfortunately I don't see any nice fix even in TreeView. One possibility is that ExplorerManager.setRootContext() will reset the selection model.
Comment 6 Jan Peska 2013-08-07 07:23:13 UTC
Unfortunately I was not able to reproduce the exact scenario with TreeView reference being kept by CompositionAreaHandler (I tried both JDK7 and JDK8), but I noticed there is MembersView reference kept in NavigatorTC after the last project is closed so I will fix that.
Comment 7 Jan Peska 2013-08-07 07:39:05 UTC
fix: http://hg.netbeans.org/core-main/rev/4fe8f3f80245
Comment 8 Quality Engineering 2013-08-08 02:30:21 UTC
Integrated into 'main-silver', will be available in build *201308072300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/4fe8f3f80245
User: Jan Peska <JPESKA@netbeans.org>
Log: Issue #233251 - memory leak in java.navigation.ElementNode
Release references after the navigator panel is empty.