Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 174713 - Leaking Document when editor is not opened (but also not closed)
Leaking Document when editor is not opened (but also not closed)
Product: platform
Classification: Unclassified
Component: Text
All All
: P3 (vote)
Assigned To: Petr Cyhelsky
Depends on:
  Show dependency treegraph
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

hg bundle to workaround the problem (678 bytes, application/octet-stream)
2009-10-16 09:13 UTC, Jaroslav Tulach
Surprise: The leak comes from Ant module, not java! (45.91 KB, image/png)
2009-10-16 14:57 UTC, Jaroslav Tulach
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

junit.framework.AssertionFailedError: Are all documents GCed? TextDocument:
private static java.util.Map org.netbeans.modules.project.ui.ProjectTab.tabs->

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:

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/
--- a/openide.nodes/src/org/openide/nodes/     Thu Oct 15 12:11:32 2009 +0200
+++ b/openide.nodes/src/org/openide/nodes/     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 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.

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo