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 253291 - OutOfMemoryError: Java heap space
Summary: OutOfMemoryError: Java heap space
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal (vote)
Assignee: Jan Stola
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-02 15:19 UTC by carlneto
Modified: 2015-09-07 13:10 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 205059


Attachments
stacktrace (2.38 KB, text/plain)
2015-07-02 15:19 UTC, carlneto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description carlneto 2015-07-02 15:19:35 UTC
Build: NetBeans IDE 8.0.2 (Build 201411181905)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.25-b02, Java(TM) SE Runtime Environment, 1.8.0_25-b17
OS: Mac OS X

User Comments:
GUEST: NetBeans freezes during a debugging session of a javascript program with chrome connector. The debugger do not seem to like web workers...

GUEST: it got stuck while editing and using inspect property

carlneto: html5 editing

GUEST: Was debuggin a javascript class




Stacktrace: 
java.lang.OutOfMemoryError: Java heap space
   at java.util.Arrays.copyOf(Arrays.java:3332)
   at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:137)
   at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:121)
   at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:421)
   at java.lang.StringBuffer.append(StringBuffer.java:272)
   at org.json.simple.JSONArray.toJSONString(JSONArray.java:91)
Comment 1 carlneto 2015-07-02 15:19:38 UTC
Created attachment 154467 [details]
stacktrace
Comment 2 Martin Entlicher 2015-07-02 17:47:00 UTC
The message that debugger received just before OOME, has 82 MB.
The full JSON object received by debugger has 500 MB!
It contains a nodes array, which has 240000 elements.
It came as "DOM.setChildNodes" notification. This is a bad design of the debugging protocol, that it can send such insane amount of data.
Comment 3 Martin Entlicher 2015-09-04 11:20:31 UTC
org.netbeans.modules.web.webkit.debugging.api.dom.Node does not clean all properties from the underlying JSON.
It retains "nodes", which is an array of other JSON objects,
it retains "params", "nodeValue", etc.

This is why Node has retains size close to the retain size of JSONObject.

But the core of the problem seems to be 220 MB retain size of 
WebKitPageModel.
Comment 4 Martin Entlicher 2015-09-04 11:23:20 UTC
Mistakenly moved instead of issue #254959. Please ignore the previous comment.
Comment 5 Jan Stola 2015-09-07 13:10:59 UTC
The heapdumps 791379 and 791038 show more than 100000 elements in the inspected page. Some time ago I added a warning for the user if this happens:
https://hg.netbeans.org/web-main/rev/6c82c8d42e2a

The heapdump 784142 shows the problem mentioned by Martin, i.e., huge message (82M) describing 240000 sub-nodes comes from Chrome. I have added a warning when we are about to request sub-node information for an element having more than 20000 sub-nodes:
https://hg.netbeans.org/web-main/rev/7b0700c9e7fa

The warnings allow the user to stop page inspection and inform him/her that (s)he may run into OutOfMemoryError if (s)he continues with the inspection/debugging.