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 157437 - java.lang.OutOfMemoryError: Java heap space
Summary: java.lang.OutOfMemoryError: Java heap space
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker with 1 vote (vote)
Assignee: Tomas Zezula
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2009-01-26 12:27 UTC by melc
Modified: 2019-05-12 16:16 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description melc 2009-01-26 12:27:42 UTC
I do a clean-build on a project and get the following error,

-------------------------------------------------------------------
init:
deps-clean:
Deleting directory C:\my folder\dev\java\projects\TestProjects\build
Deleting directory C:\my folder\dev\java\projects\TestProjects\dist
clean:
init:
deps-jar:
Created dir: C:\my folder\dev\java\projects\TestProjects\build\classes
Compiling 396 source files to C:\my folder\dev\java\projects\TestProjects\build\classes


The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space
BUILD FAILED (total time: 2 minutes 16 seconds)

---------------------------------------------------------

The project has many source files most of which (about 1000) have been excluded, through the include/exclude option at 
the project properties. As shown by the log the number of sources compiled is 396 source files. In order to avoid this 
error I have to add in the build.xml file the <target name="-init-macrodef-javac">.....</target>
as specified in the build-impl.xml overriding this target's following line,

<javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" 
excludes="@{excludes}" executable="${platform.javac}" fork="yes" includeantruntime="false" includes="@{includes}" 
source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" 
tempdir="${java.io.tmpdir}">

with this one,

<javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" 
excludes="@{excludes}" executable="${platform.javac}" fork="yes" memoryMaximumSize="1024m" includeantruntime="false" 
includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" 
tempdir="${java.io.tmpdir}">

adding the memoryMaximumSize="1024m", (512 was not enough)

The question is whether there is some other way of solving this problem. Is it an ant problem is there a way not to use 
ant from a netbeans option and not get this error? It seems to me that a lot of resources are required for not that 
large amount of files. The behaviour in 6.1 was really dissapointing sometimes the IDE just dissapeared. The memory 
options -xms and MaxPermSize have both been set to 256m in netbeans.conf (this was also necessary in 6.1 otherwise it 
just crashed).

I really like netbeans but i get the feeling that the overall memory management is an issue since the IDE seriously 
slows down or even not responds for some time when opening the whole project group or making simple changes on of the 
projects i.e. add/remove a library. The project group consists of about 10 projects each of which have about 200 source 
files.

Unforunatelly even when the IDE does not throw this error (after the patched build.xml) the time required to clean-
build is very long, sometimes the IDE might crash.
I have 2GB of RAM and a 32-bit cpu with 2 cores and 3.19 GHz
Comment 1 Milan Kubec 2009-02-03 11:58:46 UTC
Are you able to run the same script with same Ant and same JDK on command line without increased memory? 
Might be bug/memory leak in compiler.
Comment 2 Jesse Glick 2009-02-03 15:30:17 UTC
http://wiki.netbeans.org/FaqOutofMemoryOnCompile

Leaving open in case there is not already an issue (probably in j2seproject) to either set these flags automatically
when the project gets "big" (though it is very hard to predict in advance how much heap a compilation is going to need),
or at least to provide a UI for setting them, e.g.

(X) Compile inside IDE
( ) Compile externally with _____ Mb heap
Comment 3 melc 2009-02-04 09:19:38 UTC
i will try from command line and give feedback!!
Comment 4 Jan Jancura 2009-03-25 16:22:31 UTC
hmm
Comment 5 melc 2009-05-04 10:15:01 UTC
same results from command line, had to increase memory through ANT_OPTS (one of the options for assigning jvm params to 
ANT)
Comment 6 David Strupl 2012-10-25 13:41:48 UTC
Bug prior to 7.0, not touched for the last 2 years --> P4.
Comment 7 Tomas Zezula 2012-10-26 06:09:56 UTC
The UI should be added.
Comment 8 Pokemon999 2019-05-12 16:16:52 UTC
You can seen the online site here http://mycomputerwindows10.com and get the all function to access desktop computers windows 10 for the batter working.