Tuning JVM switches for performance

JVMs offer a variety of standard and non-standard switches that tune memory allocation and garbage collection behavior. Some of these settings can benefit NetBeans' performance.

Note that -X and especially -XX JVM switches are officially "unsupported" - they are often JVM or JVM-vendor specific. The switches discussed on this page are available on Sun Microsystems J2SE 1.5.0 - users of other JVM implementations may need to remove these switches in order to run NetBeans. For example, if you want to run the IDE on IBM JDK, you have to remove -J-XX:Permsize=32m and –J-XX:MaxPermSize=96m from the configuration file $NB_HOME/etc/netbeans.conf.

The documentation of Sun's JDK 5 and newer refers to Trouble-Shooting and Diagnostic Guide containing many tips how to find problems that are often related to performance.

How to specify JVM switches

Java switches are passed on the command line that starts the JVM, for example, by typing java -jar -Xmx96M someJar.jar. Since NetBeans is started by a launcher program rather than by calling java directly, the NetBeans launcher looks for these settings in a special file called netbeans.conf in etc directory of IDE instalation. Alternatively, arguments can be passed to the java process on the command line by prepending -J to them.

For example, to set the -Xmx (maximum heap size) for the JVM NetBeans will run in, edit the file called netbeans.conf in the $NB_HOME/etc directory, and include the option -J-Xmx256m or launch the ide by typing

./netbeans -J-Xmx256m

or, on Windows systems
netbeans.exe -J-Xmx256m

The netbeans.conf file can have the various JVM switches included in the text string assigned to netbeans_default_options variable. Note that the Sun JVM does not start when passed line switches it doesn't understand, but it will return a message pointing out what the problem was, for example:

java -foo
Unrecognized option: -foo
Could not create the Java virtual machine.

Generally useful switches

The following settings should produce better-than-factory setting performance on most systems. With the exception of setting the "permanent area" size, these switches have been the defaults for NetBeans for some time, and should already be in your netbeans.conf file.

More exotic switches

Listed below are some additional JVM switches which have either anecdotally or measurably impacted NetBeans performance on some, not all, systems. Your mileage may vary, but they may be worth a try.

Options affecting graphic behavior

This document contains only a small subset of switches available. More detailed description about properties affecting Java 2D(TM) behavior can be found in System Properties for Java 2D(TM) Technology document.

More exhaustive list of these options can be found at JavaTM HotSpot VM Options page that also refers to another document containing more thorough description of GC tuning.