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 67278 - Memory leak when opening JSP file
Summary: Memory leak when opening JSP file
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Marek Fukala
URL:
Keywords: PERFORMANCE
Depends on: 68023
Blocks:
  Show dependency tree
 
Reported: 2005-10-21 10:18 UTC by Antonin Nebuzelsky
Modified: 2005-11-15 20:59 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The JProfiler output showing what is not GCed after open/close of one JSP file (100.39 KB, text/html)
2005-11-03 08:53 UTC, Marek Fukala
Details
testcase (11.51 KB, patch)
2005-11-04 18:11 UTC, _ rkubacki
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antonin Nebuzelsky 2005-10-21 10:18:04 UTC
There is a suspicion on a memory leak in JSP/servlet functionality. There is a
report on nbusers about increasing memory consumption with the latest q-build.
The user did not see the suspicios increase with 5.0 beta, so this is most
probably a problem introduced after beta. I will let the user add comments to
this issue.
Comment 1 Antonin Nebuzelsky 2005-10-24 10:53:32 UTC
Here is a link to the mail on nbusers:
http://www.netbeans.org/servlets/ReadMsg?list=nbusers&msgNo=59620
Comment 2 Martin Grebac 2005-10-24 10:57:00 UTC
Would you be able to provide more info here?
Comment 3 Antonin Nebuzelsky 2005-10-24 10:59:19 UTC
Please, go and ask the user. Or try to reproduce it. I asked Petr Jiricka to
take care of this. Performance team is currently working on other high priority
issues and cannot investigate it.
Comment 4 Marek Fukala 2005-11-02 09:43:02 UTC
An email reply from the reporter:
---------
I didn't have any time lately on work to perform IDE testing -- simply returned
to the Beta after writing that message, as the qbuild was too much of a worry
for me to use in production - besides the memory issue, it also threw all kinds
of exceptions on me, esp. the embarrassing one with invalid text offsets range,
when opening a JSP in the editor. So I confirm the issue doesn't appear on the
Beta. Yes, of course, I use refactoring all the time, as well as the new CVS,
edit all kinds of content (XML, XSL, SQL, JSP tags and TLDs, etc). What I don't
do in this project at all is Swing development. Well, and I *think* I also don't
use any additional modules besides what comes built-in. The only application
server I have in the IDE is the built-in Tomcat.
--------

User confirms that he did use a lot of netbeans features including refactoring
so I do not see a reason to have this issue assigned to web module. Moreover I
think that filling issues like "suspicious memory leak" is not a good idea while
you do not have anything concrete.

I am reassigning the issue to Tonda so if you find a concrete problem related to
our modules reassign back with some steps to reproduce. Without this I cannot do
much. 
Comment 5 Antonin Nebuzelsky 2005-11-02 12:02:47 UTC
Closing as WONTFIX. At the moment perfomance team does not have cycles to audit
and proactively look where memory leaks could be. Let's hope someone will report
the problem with more details to find where the problem is.
Comment 6 kirillkh 2005-11-02 16:49:26 UTC
Unfortunately, I didn't have time to investigate this issue in depth, but I
confirm that I am able to reproduce it with the latest QBuild (31/10). Windows
task manager currently (after 2-3 hours of active usage) shows the usage of 450
Mb RAM, while NetBeans memory indicator shows 65/124MB. This never happened with
NB 4.1 or NB 5.0 Beta - the typical amount of memory the IDE used after fairly
long usage session was about 250 MB (as shown in Task Manager). I have 1GB RAM
total. I didn't change any NetBeans' start-up parameters. To give you a clue
about the size of the project, we currently have 101 classes, 54 jsps, 12 XML
custom tags (*.tag).

Additionally, I can say that during today's usage session I only edited a couple
of JSPs, performed builds of the application and ran it from the browser.
BTW, I forgot to mention the JDK version: 5.0.
Comment 7 Marek Fukala 2005-11-03 08:51:50 UTC
I found an extensive memory leak in JSP editor. Opening/closing of a JSP page
leaves a lots of hard referenced objects. I will attach an output from jprofiler
and try to fix this issue ASAP. Thanks Kiril for finding this!
Comment 8 Marek Fukala 2005-11-03 08:53:33 UTC
Created attachment 26591 [details]
The JProfiler output showing what is not GCed after open/close of one JSP file
Comment 9 Marek Fukala 2005-11-03 10:13:52 UTC
I have filled a separate issue #68023 against core/palette regarding memory leak
caused by component palette.
Comment 10 Marek Fukala 2005-11-03 12:24:13 UTC
I have filled another issue against editor module related to this: Issue #68030
- BaseDocument holding syntax instancies memory leak. This causes about 1,5kB
memory leak per JSP file opening/closing.
Comment 11 Marek Fukala 2005-11-03 13:14:24 UTC
fixed two sources of the leaking memory:
1) JspUpToDateStatusProvider used to hold a strong reference to JspColoringData
which caused that the document and a lot of connected object weren't GCed. Now a
WeakListener is used.

2) JspParserAccess held a strong reference to WebModule instance and was
registered as a listener of ClassPath which was referenced from the WM. Solution
the same as in the first case.

There is remaining "minor" problem with the leaking palette and probably the
syntaxes, but both of them doesn't cause big leaks and must be fixed in another
modules => downgrading this issue to P3.

Checking in
web/jspsyntax/src/org/netbeans/modules/web/core/syntax/JspUpToDateStatusProvider.java;
/cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/JspUpToDateStatusProvider.java,v
 <--  JspUpToDateStatusProvider.java
new revision: 1.4; previous revision: 1.3
done
Checking in
web/core/src/org/netbeans/modules/web/core/jsploader/JspParserAccess.java;
/cvs/web/core/src/org/netbeans/modules/web/core/jsploader/JspParserAccess.java,v
 <--  JspParserAccess.java
new revision: 1.11; previous revision: 1.10
done
Comment 12 Marek Fukala 2005-11-03 14:13:07 UTC
Since I have closed the issue #68030 as worksforme and the issue #68023 must be
fixed in core/palette module I am closing this issue as fixed.
Comment 13 _ rkubacki 2005-11-04 18:08:55 UTC
Marek, what's exactly the problem with listener attached to coloring data? I
thought these should disappear when editor is closed. At least the test I have
written support this and JspUpToDateStatusProvider is GC w/ weakly attached
listener as well as with normally attached.

Of course I can miss something (taglib referenced from JSP, node in explorer).
Comment 14 _ rkubacki 2005-11-04 18:11:36 UTC
Created attachment 26633 [details]
testcase
Comment 15 kirillkh 2005-11-06 23:31:36 UTC
Great work, Marek! I didn't even dream someone would actually fix this in
response to bug report as vague as that one. Looking forward to try the next
qbuild :)
Nothing to say - applause to the NetBeans team. This is why I love this IDE :)
Comment 16 Marek Fukala 2005-11-07 11:26:28 UTC
Radime, unfortunatelly I cannot get the reference graph showing the problem with
UpToDateStatusProvider anymore!?! I am not sure why (maybe a cause of another
fix) but I have verified that without the fix there is a huge number of objects
related to the NbEditorDocument instance leaking. Putting the fix back the leak
is gone. I have verified this twice. If you have problems with reproducing it
came to me and we can try to find it on my machine using the JProfiler.

A note to Kirill: Please note that during profiling this issue I have filled an
Issue #68039 (Memory leak when completion initialized) which has to be resolved
in editor module. Whithout having this fixed there will be still some objects
leaking, however AFAIK not as big as this one. Please let me know whether the
fix helped. Thanks.
Comment 17 kirillkh 2005-11-08 22:39:24 UTC
I've tried the daily from 07/11, and it seemed much better, but still ate more
and more memory. I've restarted the IDE, when it was at 450Mb, which took 4 to 5
hours of active usage.
Comment 18 Marek Fukala 2005-11-09 08:28:54 UTC
AFAIK the fix of Issue #68039 is not in 20051107 daily build. Try a newer one
please.
Comment 19 kirillkh 2005-11-09 23:31:37 UTC
I've tested the 8/11 build, and the leak was still apparent, leading to 450+
memory consumption during a couple of hours. I was mostly editing jsp, tag,
html, js and web.xml files, but also some java code.
Comment 20 Marek Fukala 2005-11-10 12:40:08 UTC
OK. That is bad, however I belive the source of the leak should not be the JSP
editor. 

You wrote that you edited some XML files so I tried to measure them and found
another "nice" memory leak. The leak is an ancient one, but recently more
objects are held because of it. For more info read Issue #68452 (XML DataObject
-> NbEditorDocument memory leak). I am going to fix it somehow today so it could
also help. But I am not so much optimistic ... sometimes it seems to me that
there is leaking almost everything... :-). I am doing my best to get rid at
least of the biggest ones. But please ... don't praize the day before evening :-)
Comment 21 kirillkh 2005-11-10 12:56:30 UTC
Hehe. However, you did fix this bug and #68039, so I still feel you deserved the
praise :)
Anyway, I'm not much worried, since I can always get back to the beta, and for
sure the problem I'm seeing will eventually get fixed for the final release.
Comment 22 kirillkh 2005-11-15 20:59:22 UTC
Marek,
I've been using the daily 200511131900 all day long and the reported issue
didn't show up. After 4 or 5 hours of active usage, the IDE consumed ~200MB, as
shown in the Windows Task Manager. This build is in many other ways better than
all the prvious builds I've tried since beta. Could it be that the fix for this
and other leaks was only included in Nov 13's release? Is there a changelog
between dailies that includes this info?
Thanks again.