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 188915 - Memory leak in ProjectAwareCodeStylePreferences
Summary: Memory leak in ProjectAwareCodeStylePreferences
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.0
Hardware: PC Linux
: P2 normal (vote)
Assignee: David Strupl
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2010-07-23 20:35 UTC by Jesse Glick
Modified: 2010-08-20 12:39 UTC (History)
0 users

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 Jesse Glick 2010-07-23 20:35:41 UTC
100723-8a8635566258. I had several NBM and Maven projects open and had done some full-text searches when I noticed RAM usage staying near the max, 500M. I closed all the projects; closed all tabs in the Usages, Output Window, and Search windows that might have contained data related to these projects; opened an unrelated small j2seproject and closed it, in case there was some cache of last-selected nodes; and did several forced GCs. The memory consumption stayed around 300M, and jmap -histo showed all the projects still loaded in memory.

I ran jhat on the dump and got a GC root reference trace for one of the Maven projects. This showed ProjectAwareCodeStylePreferences being the critical link so far as I can tell; singleton.cache holds Project's in its values, yet these Project's could strongly refer to the keys, namely NbEditorDocument's. This seemed to be the case in at least one instance: the NbMavenProjectImpl holds a document for pom.xml (via POMModelImpl). A WeakHashMap entry cannot be collected so long as the value refers to the key. The proper solution is for the values to be weak (or perhaps soft) references.
Comment 1 David Strupl 2010-08-19 11:18:14 UTC
I will try to fix this.
Comment 2 David Strupl 2010-08-20 07:57:46 UTC
http://hg.netbeans.org/jet-main/rev/376b8370f38f
Comment 3 Jesse Glick 2010-08-20 12:34:37 UTC
Should

Map<String, Csp> csps = cspsRef.get();

be

Map<String, Csp> csps = cspsRef != null ? cspsRef.get() : null;

?
Comment 4 David Strupl 2010-08-20 12:39:23 UTC
It already is thanks to Lahvac

http://hg.netbeans.org/jet-main/rev/0a7741c6d111

who fixed it faster than I noticed all our tests failure.