Friday, 29 June 2012

Reminder of my netbeans.conf file

This post is just meant to be an online reminder of my current OS X Netbeans 7.1 configuration so I can remember when I switch machines or upgrade my Netbeans version. It probably won't be too useful to others out there, but you're welcome to take a look at it nonetheless.

Also note that tuning JVM flags to work well on one machine or system configuration does not necessarily mean that it will work well on another. In fact, in some cases it can even make things worse when compared to the default settings. So if you decide to use some of the configuration below, you'll definitely want to tweak it to work well for your own machine.

Current netbeans.conf setup:

netbeans_default_options="-J-client -J-Xss2m -J-Xms1280m -J-Xmx1280m
-J-XX:PermSize=32m -J-XX:MaxPermSize=160m
-J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true -J-XX:+UseParNewGC
-J-XX:+UseConcMarkSweepGC -J-XX:+CMSParallelRemarkEnabled
-J-XX:ParallelGCThreads=3 -J-XX:+CMSClassUnloadingEnabled
-J-XX:+CMSPermGenSweepingEnabled -J-Xverify:none

(For 7.1.2, using 768m instead seems to work better as the major garbage collection cycles are much faster, and there seems to be a severe memory leak with larger amounts on the rig I'm using; the heap fills up significantly faster forcing more frequent major garbage collection cycles.)

What this is trying to do:

  • Provide enough memory to the JVM so Java doesn't frequently 'stop the world' in order to allocate more memory
  • Provide enough memory at the beginning so things don't grind to a halt in order to change the VM size early on
  • Use parallel garbage collection so Netbeans doesn't freeze for a long time when doing a major garbage collection cycle
  • Use several (but not all) cores for more efficient garbage collection
  • Make Netbeans more responsive at a slight cost of startup time
  • Provide a large enough amount of heap in order to delay time between major garbage collection cycles, also making Netbeans more responsive on average in the long run

Also note that some of the (default) flags in the configuration are there to make sure that Netbeans actually works in OS X.

Problems this is trying to solve:

The current system Netbeans is running on has ample physical memory available so a GB+ memory footprint is not an issue. However, other large programs are often used at the same time to create other resources for the same projects being developed using Netbeans. Garbage collection and memory allocations plague the system with a small VM size since opened projects can sometimes take up hundreds of MB. This creates the need to often wait for Netbeans to become responsive again after having it pause for a bit. In addition, when the system is idle for long enough, Netbeans is often paged to disk by OS X to make other programs more responsive (the current JVM flags will not be able to fix this, only more RAM will). Netbeans is often left running without restarting for weeks on end to work on parts of projects every day. The system is currently running OS X 10.7 Lion.

How well has this worked compared to the default:

The default configuration would often cause Netbeans to frequently halt when working on projects. The current configuration appears to be significantly better, without too much pausing. However, notable pauses do occur when forcing garbage collection (which doesn't appear to be necessary with the current configuration, but is still possible to do), and when loading paged memory back into RAM.


No comments:

Post a Comment