Google

Tuesday, February 24, 2009

Java Out of Memory Error - Solution

How to fix Java out of Memory Error:

http://wiki.netbeans.org/FaqOutofMemoryOnCompile

You need to increase the memory allocated to the compiler. In order to do this:

  1. Right click on the project node in the Projects window and select Properties
  2. In the project properties dialog, click on Build | Compiling
  3. In the Additional Compiler Options text box, enter the -Xmx and optionally -Xms switches as needed (for example, -J-Xms=128m -J-Xmx=512m). For JDK 6, refer to http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html.
  4. Click OK in the dialog
  5. Make sure the external javac compiler will be used, by adding the following line to nbproject/project.properties from the Files tab:
build.compiler=extJavac

That should resolve the issue.


http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html

How to set java heap size in NetBeans?
Exit NetBeans, edit the file netbeans-install/etc/netbeans.conf.

For example,
netbeans_default_options="-J-Xms512m -J-Xmx512m
-J-XX:PermSize=32m -J-XX:MaxPermSize=128m -J-Xverify:none