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 68452 - XML DataObject -> NbEditorDocument memory leak
Summary: XML DataObject -> NbEditorDocument memory leak
Status: VERIFIED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Marek Fukala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-10 12:18 UTC by Marek Fukala
Modified: 2006-03-06 13:20 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The DO -> editor document refs. chain (28.15 KB, image/png)
2005-11-10 12:22 UTC, Marek Fukala
Details
XMLDataObject -> DocumentListener -> TextEditorSupport -> NbEditorDocument leak references graph (84.49 KB, image/png)
2005-11-11 08:17 UTC, Marek Fukala
Details
After removing the mentioned strong references chain there is a new one - via XMLSyncSupport (193.93 KB, image/png)
2005-11-11 09:41 UTC, Marek Fukala
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Fukala 2005-11-10 12:18:16 UTC
I have realized that once a XMLDataObject is instantiated a XMLSyncSupport
holding a reference to EditorSupport is created a associated to it. So since the
EditorSupport holds a strong reference to NbEditorDocument the editor document
is never GCed until the DataObject lives (which is until it Node lives, which is
almost forever). 

Due to this reference chain the editor document instance is leaking for each
XMLDataObject which "content" was opened in the editor. This leak is here for a
long time and AFAIK noone complained much about it since the amount of the
memory held by one XMLDO is not critical.

A problem appears now when the XMLDocumentModel has been introduced and
associated to the NbEditorDocument once an user opens a navigator or enables the
code folding for a XML document. The model references a lot of objects and is
not GCed until the NbEditorDocument lives ...
Comment 1 Marek Fukala 2005-11-10 12:22:49 UTC
Created attachment 26823 [details]
The DO -> editor document refs. chain
Comment 2 Marek Fukala 2005-11-10 12:53:11 UTC
partially fixed - I didn't fixed the described leak itself but made the
NbEditorDocument -> DocumentModel reference weak so the DocumentModel instance
is GCed when there is only the editor holding it. I have verified in the
profiler that the leak is much smaller now. Downgrading to P3.

Checking in
xml/tageditorsupport/src/org/netbeans/modules/editor/structure/api/DocumentModel.java;
/cvs/xml/tageditorsupport/src/org/netbeans/modules/editor/structure/api/DocumentModel.java,v
 <--  DocumentModel.java
new revision: 1.15; previous revision: 1.14
done
Checking in
xml/text-edit/src/org/netbeans/modules/xml/text/navigator/XMLNavigatorPanel.java;
/cvs/xml/text-edit/src/org/netbeans/modules/xml/text/navigator/XMLNavigatorPanel.java,v
 <--  XMLNavigatorPanel.java
new revision: 1.7; previous revision: 1.6
done
Comment 3 Marek Fukala 2005-11-11 08:17:19 UTC
Created attachment 26847 [details]
XMLDataObject -> DocumentListener -> TextEditorSupport -> NbEditorDocument leak references graph
Comment 4 Marek Fukala 2005-11-11 09:41:46 UTC
Created attachment 26853 [details]
After removing the mentioned strong references chain there is a new one - via XMLSyncSupport
Comment 5 Marek Fukala 2005-11-11 14:37:57 UTC
fixed + implemented a XML navigator panels cache

The leak was caused by the XMLDataObject synchronization support which didn't
released XMLTextRepresentation object when the XML navigator was shown for a XML
file without opening it.

Checking in xml/core/src/org/netbeans/modules/xml/core/text/TextEditorSupport.java;
/cvs/xml/core/src/org/netbeans/modules/xml/core/text/TextEditorSupport.java,v 
<--  TextEditorSupport.java
new revision: 1.28; previous revision: 1.27
done
Checking in
xml/tageditorsupport/src/org/netbeans/modules/editor/structure/api/DocumentModel.java;
/cvs/xml/tageditorsupport/src/org/netbeans/modules/editor/structure/api/DocumentModel.java,v
 <--  DocumentModel.java
new revision: 1.16; previous revision: 1.15
done
Checking in
xml/text-edit/src/org/netbeans/modules/xml/text/navigator/NavigatorContent.java;
/cvs/xml/text-edit/src/org/netbeans/modules/xml/text/navigator/NavigatorContent.java,v
 <--  NavigatorContent.java
new revision: 1.18; previous revision: 1.17
done
Checking in
xml/text-edit/src/org/netbeans/modules/xml/text/navigator/XMLNavigatorPanel.java;
/cvs/xml/text-edit/src/org/netbeans/modules/xml/text/navigator/XMLNavigatorPanel.java,v
 <--  XMLNavigatorPanel.java
new revision: 1.8; previous revision: 1.7
done
Comment 6 Jiri Kovalsky 2006-03-06 13:20:22 UTC
Verifying on behalf of Marek. It would be embarrassing if one bug would be
reported, fixed and verified by single person.