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 196490 - Javascript parser errors indirectly refers to their parser result and snapshot which causes OOM during tasklist indexing
Summary: Javascript parser errors indirectly refers to their parser result and snapsho...
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.0
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: Marek Fukala
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2011-03-09 13:14 UTC by Marek Fukala
Modified: 2011-03-18 08:37 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Fukala 2011-03-09 13:14:48 UTC
The parser errors produced by the javascript parser refers to the AST Node where the error came from. However the node holds a reference to the AST and the whole JsParser result and the Snapshot.

This wouldn't be so big problem if there werent the TLIndexer (tasklist). During the files indexation it collects all the errors it gets from the given parser results. However it means that during the indexing of javascript files all the parser results, snapshots and other related objects are held. If there's more js files this inevitably lead to an OOM as it happened in the report below:

http://statistics.netbeans.org/exceptions/exception.do?id=490857
Comment 1 Marek Fukala 2011-03-10 15:15:08 UTC
Since there might always be a parser result producing Error instancies with some extensive objects map attached to the parameters field the error cannot be simply fixed at the JS side. 

The only proper way how to fix this problem securely is not to pass the org.netbeans.modules.csl.api.Error instancies directly to the ErrorsCache.setErrors() but use an artificial object which holds the minimum information required by showing the error in the tasklist. This introduces a smaller memory overhead since some of the error's fields needs to be cloned, but it is much better than holding some errors with megabytes of object attached to them.

fixed in web-main#c9421f66dbba

Honzo, can you please review the change so I can put it to 7.0? Thanks
Comment 2 Jan Lahoda 2011-03-10 16:28:22 UTC
The patch seems fine to me, thanks. Note that the idea is that TLIndexer's errors map should contain errors only from one file.
Comment 3 Marek Fukala 2011-03-10 18:58:31 UTC
(In reply to comment #2)
> The patch seems fine to me, thanks. Note that the idea is that TLIndexer's
> errors map should contain errors only from one file.

???

private static final Map<Indexable, Collection<SimpleError>> errors = new IdentityHashMap<Indexable, Collection<SimpleError>>();
Comment 4 Quality Engineering 2011-03-11 09:42:48 UTC
Integrated into 'main-golden', will be available in build *201103110400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/c9421f66dbba
User: Marek Fukala <mfukala@netbeans.org>
Log: #196490 - Javascript parser errors indirectly refers to their parser result and snapshot which causes OOM during tasklist indexing
Comment 5 Marek Fukala 2011-03-18 08:37:00 UTC
fixed in 7.0 http://hg.netbeans.org/releases/rev/c9421f66dbba