How can I improve garbage collection and memory usage in JBuilder 3.5 and my own Java programs?

By: Aaron Ruddick

Abstract: Five VM parameters that will help you tweak performance of memory usage and garbage collection.

Question:

How can I improve garbage collection and memory usage in JBuilder 3.5 and my own Java programs?

Answer:

There are five (almost totally undocumented) Java Virtual Machine parameters that you can use to tweak the performance of memory usage and garbage collection (GC):

  1. -Xms8m - minimum heap memory usage of your application.
  2. -Xmx128m - maximum heap memory usage of your application (Note: if this is to small your application may crash).
  3. -Xminf0.2 - minimum ratio of free memory used in heap after GC (0.2 seems to work well, but feel free to play with it).
  4. -Xmaxf0.2 - maximum ratio of free memory used in heap after GC (0.2 seems to work well, but feel free to play with it).
  5. -Xincgc - forces incremental garbage collection. We believe this is for hotspot only and it will not work with the "stock" JDK that is installed with JBuilder. However there is an FAQ which describes how to install Hotspot into JBuilder 3.5. Go to search.borland.com and search for "How can I improve the performance of JBuilder 3.5?" to find this FAQ.

Here is an example command line using these paramters: java -Xmx256m -Xmaxf0.25 -Xminf0.15 -Xincgc com.borland.SuperDuck

To use these parameters in JBuilder you can modify the "jbuilder.config" or "jdk.congfig" file. You will find these files located in the JBuilder35/bin directory. Here is a sample "jbuilder.config" with the new parameters:

# +-----------------------------------------------------+
# | |
# | This is the configuration file for the JBuilder IDE |
# | |
# | Do NOT make modifications without maintaining a |
# | backup copy. See README.txt for a description of |
# | the recognized directives. |
# | |
# +-----------------------------------------------------+

# Read the shared JDK definition
include jdk.config

# Tune this VM to provide enough headroom to work on large
# applications
vmparam -Xms8m
vmparam -Xmx256m

vmparam -Xminf0.2
vmparam -Xmaxf0.2

# Put the Lightweight Toolkit on the boot path
addbootpath ../lib/lwtoolkit.jar

# Add all JAR files located in the lib and libext directory
addjars ../lib
addjars ../lib/ext
#addjars c:/j2sdkee1.2/lib

# Add other database drivers here
addpath C:/DBDrivers/Oracle/classes102.zip
addpath C:/DBDrivers/Oracle/classes111.zip
addjars C:/DBDrivers/informix/driverV20/lib

# Start JBuilder using the its main class
mainclass com.borland.jbuilder.JBuilder





Server Response from: ETNASC04