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 27563 - Memory leak after opening txt/java file in editor
Summary: Memory leak after opening txt/java file in editor
Status: CLOSED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@editor
URL:
Keywords: PERFORMANCE
Depends on: 27645 28256 28270 28271 28272
Blocks: 28662 34161
  Show dependency tree
 
Reported: 2002-09-25 08:55 UTC by Marian Mirilovic
Modified: 2007-11-05 13:44 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Graph of used memory (85.71 KB, image/png)
2002-09-25 08:58 UTC, Marian Mirilovic
Details
Testing app. (1.75 KB, text/plain)
2004-03-19 21:48 UTC, Petr Nejedly
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marian Mirilovic 2002-09-25 08:55:29 UTC
[nb_dev](20020923), [jdk1.4.1](rc)

Opening file :
<sampledir>/examples/colorpicker/README.txt cause
memory consumption (used memory = allocated -
free), after 1000 iteration there are more than
5.5 MB leak (see attached graph).

Test provides actions :
- run GC (5 times)
- measure used memory (before test run)
- open README.txt
- close source editor
- run GC (5 times)
- measure used memory (after test run)
Comment 1 Marian Mirilovic 2002-09-25 08:58:15 UTC
Created attachment 7501 [details]
Graph of used memory
Comment 2 Miloslav Metelka 2002-09-25 09:27:13 UTC
Besides the graph which is nice but almost useless :-) is it possible
that you would provide e.g. the output from hat about the counts of
objects with most of the instances?
Comment 3 Marian Mirilovic 2002-09-26 09:18:20 UTC
Weel, I cannot provide your asked output, because I haven't it. We are
only looking for possible memory leaks - measn measure used memory and
trace increasing/decreasing memory footprint.

I have finished new measurement :
- opening Java file (ColorPreviewbeanInfo-2810B) : 100 iterations used
memory increased more than 500kB - means 1 opening Java file leak 5kB
memory

- opening Txt file (README-144B) : 100 iterations used memory
increased more than 400kB - means 1 opening Java file leak 4kB memory


Comment 4 Marian Mirilovic 2002-09-26 11:04:22 UTC
Changing TASK -> DEFECT.

Please start to resolve performance issues, use some profiler tool on
looking for leaks, for more inforamtion call performance team.
Comment 5 _ pkuzel 2002-10-03 13:37:49 UTC
If nobody objects I'll trace it down.
Comment 6 _ pkuzel 2002-10-03 13:41:54 UTC
Marian, could you please attach your test?
Comment 7 _ pkuzel 2002-10-04 16:58:13 UTC
I guess that NbEditorUI:278 is never deregistered. There are tons of
NbEditorUI.SystemActionUpdaters registered in TopComponent.Registry (a
pernament object).

Mila could you have a look, please?

Comment 8 _ pkuzel 2002-10-10 14:23:04 UTC
Mato is right. NbEditorUI does not cause it.

I was confused by the fact that it in its contructor registers 3
listeners at TopComponent.Registry (my test counted them and I wrongly
assumed one listener per one editor).

So I'm going to trace it down once again...
Comment 9 _ pkuzel 2002-10-23 14:18:30 UTC
Tried with disabled editor module and found a suspicious  
reference to DataEditorSupport$EnvListener. After opening a  
text file object and then closing it and closing explorer  
tree then there is suspicious reference subpath:  
  
GC root -> ..... ->  
org.netbeans.core.windows.WindowManagerImpl.updater  
(org.netbeans.core.windows.WindowManagerImpl)  
org.netbeans.core.windows.layers.WindowManagerData$InstanceCookieImpl.childrenCookies  
(org.netbeans.core.windows.layers.ICFolderImpl)  
org.netbeans.core.windows.layers.WorkspaceData$InstanceCookieImpl.childrenCookies  
(org.netbeans.core.windows.layers.ICFolderImpl)  
org.netbeans.core.windows.layers.ModeData$CookiesImpl.inst  
(org.netbeans.core.windows.layers.ICFolderImpl)  
org.netbeans.core.windows.ModeImpl.areas  
(org.netbeans.core.windows.ModeImpl)  
java.util.HashMap.table (java.util.HashMap)  
java.util.HashMap$Entry.value (java.util.HashMap.Entry)  
org.netbeans.core.windows.frames.TCCTabbedAreaImpl.selected  
(org.netbeans.core.windows.frames.TCCTabbedAreaImpl)  
org.openide.text.CloneableEditor.manager  
(org.openide.windows.TopComponent)  
org.netbeans.core.windows.WindowManagerImpl$TopComponentManager.nodes  
(org.netbeans.core.windows.WindowManagerImpl.TopComponentManager)  
org.netbeans.modules.text.TXTDataObject$TXTNode.obj  
(org.openide.loaders.DataNode)  
-> ... -> DataEditorSupport$EnvListener  
  
Field ModeImpl.areas is a map that seems to hold references 
to already closed TCs.  
Comment 10 _ pkuzel 2002-10-23 14:19:11 UTC
.. at least in MDI mode. 
Comment 11 Tomas Pavek 2002-10-24 17:41:01 UTC
Petr, do you think this can cause the problem with *multiple* files
opening? I.e. new objects are created with each open and not freed...
I think closed TopComponents are not the case (at least not visible in
memory profiler).
Comment 12 Tomas Pavek 2002-10-24 17:55:12 UTC
According to my quick investigation (which might be not complete)
using memory profiler, the memory leaks appearing here are all related
to multiple registration of the same listeners - they are not created
newly but exist all the time, just added again and again on various
places. There seem to be no other "reasonable" objects growing in
population. So all the leaked memory seems to be used just in storing
the listeners in lists, or in wrapper classes, like WeakListener or
AWTEventMulticaster. See issue 28256 for an example, more will come.
Also issue 4768127 was filed on JDK/swing (ToolTipManager causes the
leaking AWTEventMulticaster).

Real seriousness of this particular case is IMO lower, as this is an
artificial test case, users would hardly open one files 1000 times.
But generally, the accumulating listeners could be the cause of the
gradual slowing of the IDE often complained about.
Comment 13 Tomas Pavek 2002-10-25 15:08:37 UTC
Created three more issues: 28270, 28271, 28272.
Comment 14 Martin Roskanin 2003-01-29 09:44:45 UTC
The leaking object seems to be NbEditorDocument. How to easily
reproduce it:

Open text file and invoke editor context menu. Leak appears after the 

JMenuItem item =((Presenter.Popup)action).getPopupPresenter();
in NbEditorKit.NbBuildPopupMenuAction.addAction method

CCing Petr for further investigation


Comment 15 David Konecny 2003-02-21 09:51:55 UTC
See also issue 28662 - opening textfile of 27MB. I was able to open
that large file in NB editor. It takes some time, but the file opened
at the end. The problem is that after closing of file the memory was
not released. Opening file second time causes OutOfMemory. Once you
fix this issue, please test it with some very large document.
Comment 16 Petr Nejedly 2003-02-26 10:34:57 UTC
Should be fixed by fixing issue 30682
Comment 17 Marian Mirilovic 2004-02-24 11:42:38 UTC
verified in NB 3.6
Comment 18 Petr Nejedly 2004-03-19 21:40:21 UTC
By using slightly modified test from Petr Kuzel, I'm still able to
reproduce moderate memory leak (~700 bytes per opening).
I'll attach test sources and more details.
Comment 19 Petr Nejedly 2004-03-19 21:48:54 UTC
Created attachment 14061 [details]
Testing app.
Comment 20 Petr Nejedly 2004-03-19 22:12:43 UTC
There are several leaked objects, mostly cleared WeakReferences
(~17 per open/close cycle) and Integers
Some WRs and Integers come from org.netbeans.editor.Registry:
docRefs and docAct.
But most of junk WRs are in editor's impl of WeakListenerList
and WeakProperyChangeSupport.

All these classes implement some way of on-demand cleanup,
but the cleanup triggers seem to be badly chosen (e.g. most users
never change editor settings during runtime, this is why so many junk
WRs are attached to Settings).

Moreover, after my experiments and findings, I tried to provoke
cleaning by setting someting in settings. It took about a minute to
first time toggle a boolean...

I'll keem the insane heap dump, so more info on demand.
Comment 21 _ ttran 2004-03-19 22:45:49 UTC
I remember in my experimentation w/ AspectJ long time ago I saw a lot
of  PropertyChangeListeners attached to settings.  May be the same case
Comment 22 Miloslav Metelka 2004-03-23 13:48:27 UTC
Although IMHO non-significant (1500 openings to leak 1MB is non-usual
even assuming debugging sessions etc.) we should be able to fix this
into promoD.
Comment 23 Antonin Nebuzelsky 2004-08-12 15:04:12 UTC
Milo, do you think you'll fix this in promo-D? Thanks.
Comment 24 Miloslav Metelka 2004-08-12 17:07:08 UTC
Not sure maybe not. I've changed the milestone to future for sure.
Comment 25 Antonin Nebuzelsky 2004-08-31 12:38:11 UTC
See issue 48224 for much bigger memory leak. Maybe after that issue is
fixed, this one will obsolete.
Comment 26 Martin Roskanin 2004-08-31 14:05:39 UTC
Leaking mentioned in issue #48224 started since 27.08.2004, so I
believe it has no connection with this issue.
Comment 27 _ rkubacki 2006-11-16 16:38:41 UTC
I guess it is better to file new bugs like #87433 rather than reopening this old
one. This was working and there are new bugs in this area.
Comment 28 Marian Mirilovic 2007-01-10 11:30:28 UTC
v/c