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 174713 - Leaking Document when editor is not opened (but also not closed)
Summary: Leaking Document when editor is not opened (but also not closed)
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Petr Cyhelsky
URL:
Keywords: PERFORMANCE, RANDOM, REGRESSION, TEST
Depends on:
Blocks:
 
Reported: 2009-10-16 07:52 UTC by Jaroslav Tulach
Modified: 2013-07-22 11:51 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
hg bundle to workaround the problem (678 bytes, application/octet-stream)
2009-10-16 09:13 UTC, Jaroslav Tulach
Details
Surprise: The leak comes from Ant module, not java! (45.91 KB, image/png)
2009-10-16 14:57 UTC, Jaroslav Tulach
Details
Unit test simulating the failure (1.64 KB, patch)
2009-10-16 14:58 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2009-10-16 07:52:27 UTC
http://deadlock.netbeans.org/hudson/job/NB-Core-Build/3408/testReport/org.netbeans.test.ide/MemoryValidationTest/testGCDocuments/?

junit.framework.AssertionFailedError: Are all documents GCed? TextDocument:
private static java.util.Map org.netbeans.modules.project.ui.ProjectTab.tabs->
java.util.HashMap@93e411-table->
[Ljava.util.HashMap$Entry;@3542ef-[10]->
java.util.HashMap$Entry@17cf829-value->
org.netbeans.modules.project.ui.ProjectTab@1f5cf83-btv->
org.netbeans.modules.project.ui.ProjectTab$ProjectTreeView@8273c7-visHolder->
org.openide.explorer.view.TreeView$VisualizerHolder@501bee-map->
java.util.HashMap@37aea1-table->
[Ljava.util.HashMap$Entry;@be31f3-[10]->
java.util.HashMap$Entry@75e373-key->
org.openide.explorer.view.VisualizerChildren@fbda05-visNodes->
java.util.ArrayList@bf70bd-elementData->
[Ljava.lang.Object;@5e6be2-[5]->
org.openide.explorer.view.VisualizerNode@85f82d-node->
org.openide.nodes.FilterNode@1042826-original->
org.openide.nodes.CookieSet@16de563-ic->
org.openide.nodes.CookieSetLkp@da478a-tree->
org.openide.util.lookup.ArrayStorage@d1d15d-content->
[Ljava.lang.Object;@15beae8-[1]->
org.openide.nodes.CookieSetLkp$SimpleItem@1e80c8f-obj->
org.openide.text.EditorSupportLineSet@11b8a08-listener->
org.openide.text.LineListener@78ea99-root->
org.netbeans.editor.LineRootElement@4ec4fe-doc->
org.netbeans.modules.editor.NbEditorDocument@b1de2d

According to the snapshot linked from the above page, the editor is closed. So there is some potential problem with 
synchronization - the EditorSupportLineSet should keep offsets only and not the document anymore.
Comment 1 Jaroslav Tulach 2009-10-16 08:56:13 UTC
I have not reproduced the problem locally however. The command:

cd java.kit
i=0; while ant test-single -Dtest.includes=**/MemoryVali*Test* -Dtest.type=qa-functional; do i=`expr $i + 1`; echo $i; 
done; echo Finished: $i 

succeeded seven times in a row without a failure. Petr J., did you see a failure somewhere?
Comment 3 Jaroslav Tulach 2009-10-16 09:13:07 UTC
Created attachment 89591 [details]
hg bundle to workaround the problem
Comment 4 Jaroslav Tulach 2009-10-16 09:15:10 UTC
Anyone (or all of you) feeling blocked by the problem, feel free to integrate the workaround into your repository:

wget http://www.netbeans.org/nonav/issues/showattachment.cgi/89591/workaround-for-issue-174713.hg
hg unbundle workaround-for-issue-174713.hg
hg merge
hg ci -m "Merge of workaround for #174713"

I will continue investigating the real cause of the problem meanwhile.
Comment 5 Jaroslav Tulach 2009-10-16 10:37:36 UTC
I have reproduced the failure locally, but I still do not have a clue how it can happen. From the list of references 
one would say that there is an instance of org.openide.nodes.CookieSetLkp$SimpleItem which has field obj pointing to
org.openide.text.EditorSupportLineSet. But when I add debug message:

diff -r 1f650edec019 openide.nodes/src/org/openide/nodes/CookieSetLkp.java
--- a/openide.nodes/src/org/openide/nodes/CookieSetLkp.java     Thu Oct 15 12:11:32 2009 +0200
+++ b/openide.nodes/src/org/openide/nodes/CookieSetLkp.java     Fri Oct 16 11:36:50 2009 +0200
@@ -157,6 +157,10 @@
                 throw new NullPointerException();
             }
             this.obj = obj;
+            System.err.println("SimpleItem: " + obj.getClass().getName());
+            if (obj.getClass().getName().contains("EditorSupportLineSet")) {
+                Thread.dumpStack();
+            }
         }

Nothing is printed and breakpoint in the dumpStack() line does not stop.
Comment 6 Jaroslav Tulach 2009-10-16 12:54:07 UTC
I guess INSANE went insane. I managed to generate heap dump when the test fails and it claims that NbEditorDocument is 
referenced from a (Java Frame) directly. I think this means that the document is on stack of some thread that is just 
being executed. Too bad the test does not produce thread dump as well.
Comment 7 mslama 2009-10-16 14:55:49 UTC
I also was not able to find out who is responsible for this ie. who adds reference to EditorSupportLineSet in 
CookieSetLkp. Reference to document from CloneableEditorSupport->EditorSupportLineSet is cleared when document is 
closed. (Otherwise it would be reported in test.) IMO problem is not in openide.text.
Comment 8 Jaroslav Tulach 2009-10-16 14:57:42 UTC
Created attachment 89634 [details]
Surprise: The leak comes from Ant module, not java!
Comment 9 Jaroslav Tulach 2009-10-16 14:58:18 UTC
Created attachment 89635 [details]
Unit test simulating the failure
Comment 10 Jaroslav Tulach 2009-10-16 15:32:10 UTC
core-main#04860c675e0c definitely helps with the memory leak. Hopefully it will not release ESLineSet too often.
Comment 11 Jesse Glick 2009-10-16 15:36:18 UTC
Not really related to the Ant module per se, I guess - would happen if the selected node in Projects tab were any file
with an editor.
Comment 12 Jesse Glick 2009-10-16 15:38:00 UTC
jtulach - you need to also push your workaround 2696ffe89ea8 to core-main, I guess also with a follow-up changeset that
backs it out. This will restore the test after it has been disabled on team builders. (I pushed the workaround to cdev
and others may be doing the same in other builders.)
Comment 13 Jaroslav Tulach 2009-10-16 21:30:28 UTC
I'll enable the test as soon as beta is branched.
Comment 14 Vitezslav Stejskal 2009-10-30 14:28:03 UTC
I backed out http://hg.netbeans.org/main-golden/rev/04860c675e0c due to several P1 regressions - see issue #175578,
issue #175646.
Comment 15 Vitezslav Stejskal 2009-10-30 14:31:04 UTC
Since this is random and so far has only been reported from tests I'm lowering the priority to P3.
Comment 16 David Strupl 2012-10-25 13:39:29 UTC
Bug prior to 7.0, not touched for the last 2 years --> P4.
Comment 17 David Strupl 2012-10-26 12:41:05 UTC
Petr, can you pleease have a look? Is this still a problem? Thanks.
Comment 18 Petr Cyhelsky 2013-07-22 11:51:16 UTC
This is no longer a problem, must have been fixed in the meantime.