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 ?

Frank
  • 30,590
  • 58
  • 161
  • 244

1 Answers1

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.

Costis Aivalis
  • 13,680
  • 3
  • 46
  • 47
  • 5
    Great answer, thanks. It would be nice to be able to set this from Netbeans' GUI, like Options -> Setting ... – Frank Sep 25 '13 at 16:11
  • 10
    What about real GUI programmers? Do they use GUIs? :-) – Costis Aivalis Feb 28 '15 at 21:12
  • 4
    A local version of this file can be created unter `~/.netbeans//etc/netbeans.conf`, the `etc` dir has to be created manually. – scai Apr 26 '16 at 08: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. – Brian Knoblauch Jul 13 '17 at 19:09
  • 3
    Note that with Java 8, the PermSize parameter is no longer needed. It will be ignored. – Enwired Aug 10 '17 at 17:09