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 86937 - Huge memory leak in C++ editing support
Summary: Huge memory leak in C++ editing support
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 5.x
Hardware: All All
: P1 blocker (vote)
Assignee: Alexander Simon
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2006-10-11 14:51 UTC by _ rkubacki
Modified: 2007-09-06 18:10 UTC (History)
1 user (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 _ rkubacki 2006-10-11 14:51:17 UTC
NB5.5rc2 + cnd cluster from Oct 9 taken from internal Sun's machine
phoenix.czech, JDK 1.6.0_b99

C++ editor has a huge memory leak - once the file is edited its document
(org.netbeans.modules.editor.NbEditorDocument) associated TopComponent
(org.netbeans.modules.cnd.loaders.CppEditorSupport$CppEditorComponent)
completion and various other things are never released from memory.

I created heap dump to find this reference chain:

Static reference from
org.netbeans.modules.cnd.editor.parser.CppMetaModel.instance (from class
org.netbeans.modules.cnd.editor.parser.CppMetaModel) :
--> org.netbeans.modules.cnd.editor.parser.CppMetaModel@0xc37a9d68 (16 bytes)
(field map:)
--> java.util.HashMap@0xc37b0a18 (40 bytes) (field table:)
--> [Ljava.util.HashMap$Entry;@0xc37b2f10 (72 bytes) (Element 4 of
[Ljava.util.HashMap$Entry;@0xc37b2f10:)
--> java.util.HashMap$Entry@0xc5699e40 (24 bytes) (field next:)
--> java.util.HashMap$Entry@0xc37b5ae8 (24 bytes) (field value:)
--> org.netbeans.modules.cnd.editor.parser.CppFile@0xc37b7210 (64 bytes) (field
doc:)
--> org.netbeans.modules.editor.NbEditorDocument@0xc3768c48 (196 bytes) (field
listenerList:)
--> javax.swing.event.EventListenerList@0xc376bef0 (12 bytes) (field listenerList:)
--> [Ljava.lang.Object;@0xc5b5b7d8 (16 bytes) (Element 1 of
[Ljava.lang.Object;@0xc5b5b7d8:)
--> org.netbeans.lib.editor.util.swing.PriorityDocumentListenerList@0xc377d0e0
(12 bytes) (field listenersArray:)
--> [[Ljava.util.EventListener;@0xc5ba1d90 (20 bytes) (Element 2 of
[[Ljava.util.EventListener;@0xc5ba1d90:)
--> [Ljava.util.EventListener;@0xc5ba1d70 (24 bytes) (Element 1 of
[Ljava.util.EventListener;@0xc5ba1d70:)
--> org.netbeans.editor.ext.Completion$1CompletionDocumentListener@0xc37cab08
(12 bytes) (field this$0:)
--> org.netbeans.modules.cnd.completion.cplusplus.NbCsmCompletion@0xc37b9970 (80
bytes) (field extEditorUI:)
--> org.netbeans.modules.editor.NbEditorUI@0xc3768b88 (186 bytes) (field
toolBarComponent:)
--> org.netbeans.modules.editor.NbEditorToolBar@0xc378ac98 (340 bytes) (field
component:)
--> [Ljava.awt.Component;@0xc3794bc8 (132 bytes) (Element 0 of
[Ljava.awt.Component;@0xc3794bc8:)
-->
org.netbeans.modules.cnd.qnavigator.NavigateAction$ToolbarPresenter@0xc37960b8
(332 bytes) (field explorerView:)
--> org.netbeans.modules.cnd.qnavigator.NavigationView@0xc3794358 (446 bytes)
(field topComponent:)
-->
org.netbeans.modules.cnd.loaders.CppEditorSupport$CppEditorComponent@0xc3768d18
(383 bytes)

After 'cvs co -r release55 cnd' it is apparent that CppMetaModel that is a
singleton manages its map <doc. title; CppFile> in a wrong way. There are only
put() and get() calls. CppFile then hold strong reference to document and
through couple of other reference you can get to a lot of object...

I did just helloworld and examples and with 9 files opened memory utilization
cannot fall below 85MB.
Comment 1 Alexander Simon 2006-10-12 16:50:57 UTC
fixed by:
-remove unused reference on NB document in CppFile
-cleanup NavigationView on removeNotify()

CVS log:

Checking in qnavigator/src/org/netbeans/modules/cnd/qnavigator/NavigationView.java;
/shared/data/ccvs/repository/cnd/qnavigator/src/org/netbeans/modules/cnd/qnavigator/NavigationView.java,v
 <--  NavigationView.java
new revision: 1.2.2.5; previous revision: 1.2.2.4
done
Checking in qnavigator/src/org/netbeans/modules/cnd/qnavigator/NavigateAction.java;
/shared/data/ccvs/repository/cnd/qnavigator/src/org/netbeans/modules/cnd/qnavigator/NavigateAction.java,v
 <--  NavigateAction.java
new revision: 1.2.2.2; previous revision: 1.2.2.1
done
Checking in src/org/netbeans/modules/cnd/editor/parser/CppFile.java;
/shared/data/ccvs/repository/cnd/src/org/netbeans/modules/cnd/editor/parser/CppFile.java,v
 <--  CppFile.java
new revision: 1.2.2.2; previous revision: 1.2.2.1
done

Comment 2 Vladimir Voskresensky 2006-10-17 09:20:58 UTC
opened separate P3 http://www.netbeans.org/issues/show_bug.cgi?id=87265 for
memory leak in CppMetaModel.