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 191497 - [70cat]IDE becomes slow when editing large HTML file
Summary: [70cat]IDE becomes slow when editing large HTML file
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Parsing & Indexing (show other bugs)
Version: 7.0
Hardware: PC Linux
: P2 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords: PERFORMANCE
: 187008 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-10-31 10:41 UTC by schkovich
Modified: 2010-11-25 15:40 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
snapshot (43.73 KB, application/x-netbeans-profiler)
2010-10-31 10:45 UTC, schkovich
Details
message log (68.76 KB, application/octet-stream)
2010-10-31 10:45 UTC, schkovich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description schkovich 2010-10-31 10:41:42 UTC
Product Version = NetBeans IDE Dev (Build 201010300000)
Operating System = Linux version 2.6.35-22-generic running on amd64
Java; VM; Vendor = 1.6.0_22
Runtime = Java HotSpot(TM) 64-Bit Server VM 17.1-b03

I got messy 3000 lines long HTML file needed to be formatted and correct problems.

I can work for around 15 minutes. Entire allowed memory is used, IDE becomes slow and eventually crash.
Comment 1 schkovich 2010-10-31 10:45:31 UTC
Created attachment 102728 [details]
snapshot
Comment 2 schkovich 2010-10-31 10:45:46 UTC
Created attachment 102729 [details]
message log
Comment 3 Marek Fukala 2010-11-08 13:24:28 UTC
Looks like out of memory problem, everything runs extremely slow, nothing suspicious in the snapshot.

Would you mind attaching the file to the issue or send it directly to me? Thanks
Comment 4 Marek Fukala 2010-11-22 13:18:12 UTC
I've received the problematic file by email, it cannot be made public. I'm going to play with it a bit to see if the described problems happen.
Comment 5 Marek Fukala 2010-11-22 15:06:05 UTC
There seem to be a serious memory leak in the 

org.netbeans.modules.parsing.impl.SourceCache class. Its field 

Map<Embedding,SourceCache> embeddingToCache indirectly holds all embedded parser results created during a Source object lifecycle.

After taking several heapdumps in a row, editing a huge html file with many javascript and css embedded code and running GC between the dumps I realized that the number of embedded parser results for all embedded languages (JS and CSS) is increasing and these results are never GCed, since held by the SourceCache, at least until the file is opened. After several edits of the big file I ended up with +30MB of memory not being able to GC. Each parser results holds quite extensive chunk of objects, mainly the AST nodes and references to the tokens.

Please address this issue ASAP since it really makes the IDE unusable for editing of bigger files with some embedded code.

BTW, the old html parser results (for .html files) are GCed correctly, the problem happens only for the embedded parser results.

There are several complains about the web editors performance which I believe are caused mainly by this issue.

I consider this issue to be at least P2.
Comment 6 Tomas Zezula 2010-11-22 15:16:54 UTC
Not sure with the evaluation as the class has no relevant change for 1/2y.
Comment 7 Tomas Zezula 2010-11-22 15:30:40 UTC
Please attach (send) the file causing this issue. The embeddingToCache is cleaned by updateEmbeddings.

>There are several complains about the web editors performance which I believe are caused mainly by this issue.
Not sure as I have several snapshots where html parser takes order of minutes.
Comment 8 Tomas Zezula 2010-11-22 17:24:14 UTC
I've look into it. There is a memory leak but not so big as you describe. It's affected only by PM.parse(). This leak seems to be there from the beginning of parsing api. I am working on it.
Comment 9 Tomas Zezula 2010-11-22 18:35:42 UTC
Fixed jet-main 38bef69a6168
Anyway I doubt it the root case of slow HTML support (the mem leak was there from beginning).
Comment 10 Marek Fukala 2010-11-22 19:01:10 UTC
Thanks for fixing Tome! 

As for the cause... sure, it is definitively not the only problem, but for big files with lots of js a css inside this used to be a real problem. After a while of editing you ended up with many parser results holding extensive trees of objects.

I believe this particular problem with OOM is caused by this issue.

I do not understand what's exactly ment by "It's affected only by PM.parse()".
Comment 11 Marek Fukala 2010-11-22 19:10:46 UTC
>Not sure as I have several snapshots where html parser takes order of minutes.

Just the parsing? Can you attach here the snapshots? I'm really curious...
Comment 12 Marek Fukala 2010-11-23 11:12:50 UTC
I confirm that the memory leak in SourceCache is now fixed.
Comment 13 Tomas Zezula 2010-11-23 12:30:06 UTC
Thanks Marku
Comment 14 Quality Engineering 2010-11-24 06:10:59 UTC
Integrated into 'main-golden', will be available in build *201011240001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/38bef69a6168
User: Tomas Zezula <tzezula@netbeans.org>
Log: #191497:[70cat]IDE becomes slow when editing large HTML file
Comment 15 schkovich 2010-11-24 15:37:48 UTC
I was editing HTML used when reporting the bug for 20 minutes without a problem.
Comment 16 Marek Fukala 2010-11-25 15:40:36 UTC
*** Bug 187008 has been marked as a duplicate of this bug. ***