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 239940 - OutOfMemoryError: Java heap space
Summary: OutOfMemoryError: Java heap space
Status: VERIFIED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: All All
: P2 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords: 8.0_HR_FIX
Depends on:
Blocks:
 
Reported: 2014-01-03 03:34 UTC by Cynara
Modified: 2014-02-25 12:51 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 200994


Attachments
stacktrace (3.02 KB, text/plain)
2014-01-03 03:34 UTC, Cynara
Details
Biggest Char[] (15.52 KB, image/png)
2014-02-19 10:06 UTC, Tomas Zezula
Details
Snapshot (84.59 KB, image/png)
2014-02-19 10:25 UTC, Tomas Zezula
Details
PHP part patch (2.61 KB, patch)
2014-02-19 13:31 UTC, Ondrej Brejla
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cynara 2014-01-03 03:34:01 UTC
Build: NetBeans IDE 7.4 (Build 201310111528)
VM: Java HotSpot(TM) 64-Bit Server VM, 24.45-b08, Java(TM) SE Runtime Environment, 1.7.0_45-b18
OS: Windows 7

User Comments:
GUEST: ??php??????

GUEST: Start the virtualbox.

GUEST: <Please provide a description of the problem or the steps to reproduce>,

GUEST: I'm not doing anything, it just crashed.

GUEST: I don't know, as I didn't see the error happen.

GUEST: DONT KNOW!

GUEST: Switch between project groups

GUEST: Shutdown IDE

Cynara: error happened on start-up

GUEST: OutOfMemoryError<Please provide a description of the problem or the steps to reproduce>

GUEST: ?????? ????? ?????? ???????? ??-?? ?????? ????? ?? ???? ?????? ??????????? ??????.

GUEST: ?

GUEST: I have no idea how this happened

GUEST: boh

GUEST: just opened netbeans.

GUEST: asd

GUEST: damn

GUEST: dont have a c

GUEST: Waiting for background scanning, which takes forever. Out of Memort the moment I clicked the profiler button. I havent altered any heap space settings from the jvm defaults, this seems like a memory leak to me, happens when I open a particular project however I'm not aware of what it is about that project that NB doesnt like.




Stacktrace: 
java.lang.OutOfMemoryError: Java heap space
   at java.util.Arrays.copyOf(Arrays.java:2367)
   at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:130)
   at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:114)
   at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:415)
   at java.lang.StringBuilder.append(StringBuilder.java:132)
   at java.lang.StringBuilder.append(StringBuilder.java:179)
Comment 1 Cynara 2014-01-03 03:34:03 UTC
Created attachment 143575 [details]
stacktrace
Comment 2 Exceptions Reporter 2014-01-09 02:24:44 UTC
This bug already has 20 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=200994
Comment 3 Tomas Zezula 2014-02-18 18:25:59 UTC
And the winner is org.netbeans.modules.php.editor.PhpEmbeddingProvider which creates 2 nearly 150MB snapshots from 5M file - heapdump-710293. In the heapdump-707265 133MB snapshots are created from 777KB file.
Comment 4 Ondrej Brejla 2014-02-19 09:44:00 UTC
Sorry, but everything seems to be ok on php.editor side. From that big file...PhpEmbeddingProvider just creates one big HTML embedding. From offset 63 with length 2772223. First 63 chars are properly skipped as PHP tokens.

The rest of the file (html part) looks like:

2014-01-17 00:00:01 --- INFO: Executing minutely cron script
2014-01-17 00:01:01 --- INFO: Executing minutely cron script

So it's not HTML at all...maybe HTML parser/lexer itself has a problem with it? Really don't know, but PHP part is imho ok.

In fact this usecase is very uncommon. That problematic "php" file is just a log file with a php header (to ensure that noone will read that log file...probably it is accessible by URL). Imho not P2. Reassigning back for further evaluation, thanks.

Just one thing...this implementation of PhpEmbeddingProvider is there since 2009 with just minor changes.
Comment 5 Tomas Zezula 2014-02-19 09:56:31 UTC
Look to the heap dump and think.
> but everything seems to be ok on php.editor side
Sounds a joke to me if you create 150MB from 700KB and saying everything is OK you are probably joking.
Comment 6 Tomas Zezula 2014-02-19 10:05:21 UTC
Here are important data to look for (owner).

org.netbeans.modules.php.editor.PhpEmbeddingProvider.getEmbeddings(PhpEmbeddingProvider.java:123)
	   Local Variable: java.util.ArrayList#9576
	   Local Variable: org.netbeans.api.lexer.TokenSequence#3
	   Local Variable: org.netbeans.api.lexer.TokenHierarchy#3
	at org.netbeans.modules.parsing.impl.TaskProcessor.callEmbeddingProvider(TaskProcessor.java:583)
	at org.netbeans.modules.parsing.impl.SourceCache.getAllEmbeddings(SourceCache.java:307)
	   Local Variable: java.util.ArrayList$Itr#19
	   Local Variable: java.util.HashSet#7895
	   Local Variable: java.util.LinkedHashMap#689
	   Local Variable: java.util.ArrayList#9577
	   Local Variable: org.netbeans.modules.php.editor.PhpEmbeddingProvider#2
	   Local Variable: org.netbeans.modules.parsing.api.Snapshot#3
Comment 7 Tomas Zezula 2014-02-19 10:06:35 UTC
Created attachment 145395 [details]
Biggest Char[]
Comment 8 Tomas Zezula 2014-02-19 10:07:51 UTC
The attached screenshot shows a 133MB embedding (2 of them).
Comment 9 Tomas Zezula 2014-02-19 10:25:10 UTC
Created attachment 145396 [details]
Snapshot

The following screenshot may be also helpful.
Showing Snapshot holding 66M chars -> 133MB, the snapshot is of type text/x-php5.
The important pars are marked red.
Comment 10 Ondrej Brejla 2014-02-19 13:31:02 UTC
Created attachment 145398 [details]
PHP part patch

Ok, so after offline discussion with Tomas, here is my PHP part patch...no html embeddings are created if their length is bigger than 5M.
Comment 11 Tomas Zezula 2014-02-19 13:33:58 UTC
Perfect Ondro!
I am trying to do some general stuff when EmbeddingProvider creates an Embedding > 50MB ignore such an Embedding, and do not parse files > 50MB.
The 50MB will be overridable by system property if someone needs to works with bigger files.
Comment 12 Ondrej Brejla 2014-02-19 13:35:24 UTC
Great, thanks.
Comment 13 Ondrej Brejla 2014-02-19 13:46:46 UTC
Well, so I'll push my patch to web-main and you will close this issue once you write your part? And e.g. tomorrow or on Friday we can backport our changes to 80_base branch if it will be created and changes will be propagated to main, right?
Comment 14 Ondrej Brejla 2014-02-19 15:10:06 UTC
PHP part fixed in web-main #56778b95a8f3
Comment 15 Tomas Zezula 2014-02-19 15:46:48 UTC
The generic part fixed jet-main efc3977ff68b
Comment 16 Quality Engineering 2014-02-20 03:04:50 UTC
Integrated into 'main-silver', will be available in build *201402200001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/efc3977ff68b
User: Tomas Zezula <tzezula@netbeans.org>
Log: #239940:OutOfMemoryError: Java heap space
Comment 17 Dusan Balek 2014-02-20 13:43:12 UTC
The generic part fix seems good to me.
Comment 18 Tomas Zezula 2014-02-20 14:13:22 UTC
Generic part transplanted bf3e5c6d1587, b598fe2d5faf
Comment 19 Martin Fousek 2014-02-20 14:18:11 UTC
The PHP patch seems good to me.
Comment 20 Ondrej Brejla 2014-02-20 14:25:16 UTC
PHP part transplanted in releases #d9789d6a437f
Comment 21 Quality Engineering 2014-02-21 01:29:43 UTC
Integrated into 'releases/release80', will be available in build *201402202300* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/bf3e5c6d1587
User: Tomas Zezula <tzezula@netbeans.org>
Log: #239940:OutOfMemoryError: Java heap space
Comment 22 mmolda 2014-02-25 12:51:20 UTC
I'm not able to reproduce it, verified. Thanks

Product Version: NetBeans IDE 8.0 RC1 (Build 201402242200)
Java: 1.8.0; Java HotSpot(TM) 64-Bit Server VM 25.0-b67
Runtime: Java(TM) SE Runtime Environment 1.8.0-b126
System: Windows 7 version 6.1 running on amd64; Cp1250; en_US (nb)