51

I have 24 GB of RAM on my PC, but sometimes when Netbeans compiles my projects, it says not enough memory to compile it, I looked at the memory useage, it shows : 586/590 M.

So how to tell Netbeans, there are plenty of RAM, use as much as you need ?

1
  • 16
    +1 use as much as you need? I have this conversation with netbeans everyday. It's an endless battle. Commented Apr 2, 2014 at 6:19

1 Answer 1

69

In the etc directory under your Netbeans-Home, edit the file netbeans.conf file. -Xms and -Xmx should be increased to the values that allow your program to compile.

Here are the instructions in netbeans.conf:

# Note that default -Xmx and -XX:MaxPermSize are selected for you automatically.
# You can find these values in var/log/messages.log file in your userdir.
# The automatically selected value can be overridden by specifying -J-Xmx or
# -J-XX:MaxPermSize= here or on the command line.

Put the values in the netbeans_default_options string. Here is mine (remove linebreaks, added for readability):

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m 
-J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true 
-J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true 
-J-Dsun.zip.disableMemoryMapping=true  -J-Dsun.awt.disableMixing=true 
-J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd --laf Nimbus"

EDIT: -J-Xms sets the minimum Java heap size, -J-Xmx sets the maximum Java heap size.

5
  • 5
    Great answer, thanks. It would be nice to be able to set this from Netbeans' GUI, like Options -> Setting ...
    – Frank
    Commented Sep 25, 2013 at 16:11
  • 10
    What about real GUI programmers? Do they use GUIs? :-) Commented Feb 28, 2015 at 21:12
  • 4
    A local version of this file can be created unter ~/.netbeans/<version>/etc/netbeans.conf, the etc dir has to be created manually.
    – scai
    Commented Apr 26, 2016 at 8:55
  • 1
    @Mike.R The run option from the GUI only changes it for your application. For netbeans itself you need to adjust the configuration file. Commented Jul 13, 2017 at 19:09
  • 3
    Note that with Java 8, the PermSize parameter is no longer needed. It will be ignored.
    – Enwired
    Commented Aug 10, 2017 at 17:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.