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 63730 - There is a memory leak in editor
Summary: There is a memory leak in editor
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 5.x
Hardware: All All
: P1 blocker (vote)
Assignee: Pavel Flaska
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2005-09-06 17:39 UTC by Marek Fukala
Modified: 2007-11-05 13:44 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot of the profiler window (68.21 KB, image/png)
2005-09-07 10:03 UTC, Marek Fukala
Details
INSANE output (6.78 KB, text/plain)
2005-09-08 16:23 UTC, _ rkubacki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Fukala 2005-09-06 17:39:39 UTC
I tried to run JProfiles several times after opening / closing a XML file and
realized that there is a DocumentModel instance in memory leaking. It has
hardlinks to Document instance and plenty of DocumentElements. 

It also causes a performance problem after several closing / opening of the same
file.
Comment 1 Marek Fukala 2005-09-06 17:40:24 UTC
I will try to fix it ASAP...
Comment 2 Marek Fukala 2005-09-07 10:02:23 UTC
After a few hours spent in imagination of where can be the damned reference to
the DocumentModel instance and thinking about the weekness of the world I
realized that the problem is on the editor side :-).  Then I tried to profile
memory for other editor types and realized that the problem happed for all of
them (I tried XML/DTD/java/plain). I am attaching a screenshot of the profiler
where is clearly visible that a plenty of instancies connected to
NbEditorDocument is allocated and cannot be garbage collected.

How I tested the leak:
1) open a plain text document in the editor
2) close it
=> 2 new instancies of NbEditorDocument + tons of related objects are allocated
and hard-referenced somehow (I didn't go throught all of the reference graphs)
3) open the document again
4) close it again
=> next 2 new instancies + plenty of thers

I tried to run GC after the open/close several times, but the objects are not GCed.

Reassigning to editor.
Comment 3 Marek Fukala 2005-09-07 10:03:34 UTC
Created attachment 24565 [details]
Screenshot of the profiler window
Comment 4 Marek Fukala 2005-09-07 10:05:32 UTC
I am not sure whether the priority is set correctly - quite big amount of memory
can leak for some editor types. Radime, can you please take look at it?
Comment 5 _ rkubacki 2005-09-07 10:23:52 UTC
I am a bit busy these days but I will try.
Comment 6 Antonin Nebuzelsky 2005-09-07 13:55:01 UTC
Marku, thanks for finding this. It is P1, must fix for Beta.
The size of the leak is large. It can be a few megs for some of the newly opened
files (sometimes it is less), but also hundreds of kilobytes for each file
reopening.

Editor team, please, evaluate ASAP.
Comment 7 Miloslav Metelka 2005-09-07 14:13:46 UTC
Reassigning to Honza B.
Comment 8 Pavel Flaska 2005-09-07 14:30:09 UTC
Honza doesn't have installed profiler, so I will take this.
Comment 9 Miloslav Metelka 2005-09-07 15:18:02 UTC
I suspect that it could be related to listening on MimeLookup. The listener on
MimeLookup's result should be weak as the result can be referenced by multiple
objects and some of them can be alive.
Comment 10 Marek Fukala 2005-09-08 09:32:24 UTC
just subject change
Comment 11 Pavel Flaska 2005-09-08 13:35:18 UTC
Leak is caused by this integration:

Directory: /editor/src/org/netbeans/modules/editor/
===================================================

File [changed]: NbEditorUI.java
Url:
http://editor.netbeans.org/source/browse/editor/src/org/netbeans/modules/editor/NbEditorUI.java?r1=1.35&r2=1.36
Delta lines:  +132 -2
---------------------
--- NbEditorUI.java	12 Aug 2005 15:15:58 -0000	1.35
+++ NbEditorUI.java	26 Aug 2005 12:22:22 -0000	1.36
Comment 12 Pavel Flaska 2005-09-08 15:01:58 UTC
Checking in org/netbeans/modules/editor/NbEditorUI.java;
/cvs/editor/src/org/netbeans/modules/editor/NbEditorUI.java,v  <--  NbEditorUI.java
new revision: 1.40; previous revision: 1.39
done
Comment 13 _ rkubacki 2005-09-08 16:16:55 UTC
I tried to reproduce it and check what INSANE can do. Here is simple to do list.

- add insane module to the IDE. 'ant -f performance/insane/build.xml'
- run the IDE and reproduce the leak (open/close few files) and then generate a dump
- create a simple project depending on performance/insanelib, use modified
version of DemoQuery contained in performance/insanelib/demo to find instances
of NbEditorDocument and their traces from root
- analyze the output
Comment 14 _ rkubacki 2005-09-08 16:23:54 UTC
Created attachment 24638 [details]
INSANE output
Comment 15 _ rkubacki 2005-09-08 16:25:48 UTC
leaks through anonymous inner class in NbEditorUI held from MIME lookup are
visible in the output
Comment 16 Antonin Nebuzelsky 2005-09-12 17:05:50 UTC
Verified with profiler as fixed. Thanks!