Improve the performance of Netbeans
Written by coregps on Tuesday, March 21st, 2006 in Java.
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
I’m running Netbeans 5.0 with JDK 1.5.0_06 on Windows XP. It is getting more and more slow, especially during the garbage collection. I found some tunning tips on the NetBeans site.
1. Disable the modules that you don’t use. With NetBeans 5.x use Tools | Module Manager to display a dialog allowing you to configure modules.
2. Try switching to a different garbage collection algorithm and tunning JVM switches. This can be done by setting the following options in the configuration file $NB_HOME/etc/netbeans.conf.
- -J-Xverify:none - this switch turns off Java bytecode verification, making classloading faster, and eliminating the need for classes to be loaded during startup solely for the purposes of verification. This switch improves startup time, and there is no reason not to use it.
- -J-Xms32m - this setting tells the Java virtual machine to set its initial heap size to 32 megabytes. By telling the JVM how much memory it should initially allocate for the heap, we save it growing the heap as NetBeans consumes more memory. This switch improves startup time. It is used by default in NetBeans, so you do not need to specify it.
- -J-Xmx256m - this settings tells the Java virtual machine the maximum amount of memory it should use for the heap. Placing a hard upper limit on this number means that the Java process cannot consume more memory than physical RAM available. This limit can be raised on systems with more memory. Current default value is 128MB. Note: Do not set this value to near or greater than the amount of physical RAM in your system or it will cause severe swapping during runtime. On machines with limited memory (less than 384MB), it is recommended that you set the initial heap size lower than the default. Open the configuration file etc/netbeans.conf in a text editor and modify the options in netbeans_default_options setting. Decrease the option -J-Xmx128m to -J-Xmx96m and the option -J-XX:MaxPermSize=96m to -J-XX:MaxPermSize=64m.
- -J-XX:+UseConcMarkSweepGC or -J-XX:+UseParNewGC - try these switches if you are having problems with intrusive garbage collection pauses. This switch causes the JVM to use different algorithms for major garbage collection events (also for minor collections, if run on a multiprocessor workstation), ones which do not “stop the world” for the entire garbage collection process. You should also add the line -J-XX:+CMSClassUnloadingEnabled and -J-XX:+CMSPermGenSweepingEnabled to your netbeans.conf file so that class unloading is enabled (it isn’t by default when using this collector).
- -XX:+UseAdaptiveSizePolicy - this switch may help improve garbage collector throughput and memory footprint. It is part of garbage collector ergonomics implemented in JDK5.0.
- -J-XX:+UseParallelGC - some tests have shown that, at least on systems fairly well equipped with memory, the durations of minor garbage collections is halved when using this collection algorithm, on uniprocessor systems. Note that this is paradoxical - this collector is designed to work best on multiprocessor systems with gigabyte heaps. No data is available on its effect on major garbage collections. Note: this collector is mutually exclusive with -J-XX:+UseConcMarkSweepGC.
- -J-XX:CompileThreshold=100 - this switch will make startup time slower, by HotSpot to compile many more methods down to native code sooner than it otherwise would. The reported result is snappier performance once the IDE is running, since more of the UI code will be compiled rather than interpreted. This value represents the number of times a method must be called before it will be compiled.
After modifying some options above, my Netbeans IDE works faster than before
The following is my netbeans.conf file.
# ${HOME} will be replaced by JVM user.home system property
netbeans_default_userdir="${HOME}/.netbeans/5.0"
# options used by netbeans launcher by default, can be overridden by explicit
# command line switches
#netbeans_default_options="-J-Xms32m -J-Xmx128m -J-XX:PermSize=32m -J-XX:MaxPermSize=96m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true"
# --- tips for more advanced options you could use ---
# for JDKs where it is supported (for example Sun's JDK 5.0 and newer),
# you can use the following set of options which enable Concurrent Mark and
# Sweep garbage collection algorithm and improve UI responsiveness
# (see FAQ item http://www.netbeans.org/kb/faqs/performance.html#FaqGCPauses)
netbeans_default_options="-J-Xms32m -J-Xmx128m -J-XX:PermSize=32m -J-XX:MaxPermSize=96m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled -XX:+UseAdaptiveSizePolicy -J-XX:CompileThreshold=100"
# ---
# default location of J2SE JDK, can be overridden by using --jdkhome <DIR> switch
netbeans_jdkhome="C:Program FilesJavajdk1.5.0_06"
# clusters' paths separated by path.separator (semicolon on Windows, colon on Unices)
#netbeans_extraclusters="/absolute/path/to/cluster1:/absolute/path/to/cluster2"
For more information about Netbeans performance tuning, visit:
http://performance.netbeans.org/howto/jvmswitches/index.html
http://www.netbeans.org/kb/faqs/performance.html#FaqGCPauses










