heapview

ECLIPSE HEAP USAGE VIEWER PLUGIN

Web Age Solutions Inc.

INTRODUCTION

Memory usage by Eclipse or any Eclipse based product such as Rational Application Developer (RAD) can suffer from two memory related bottlenecks.

  1. The maximum memory limit is set too low. If you are developing a large project, Eclipse may run out of memory and crash.
  2. The initial heap size is set too low. As a result, the JVM has to continuously grow the heap. This happens primarily when Eclipse starts up. Growing the heap is expensive. You can not simply set an arbitrarily high initial heap. A very large heap will significantly slow down the garbage collection process, as system needs to inspect a large number of objects.

You can use the heap viewer plugin to accurately estimate the heap needs of Eclipse. This will help you set the optimal maximum and initial value of the heap size.

The plugin has been tested using Eclipse 3.1 and RAD 6.0.1.

INSTALLATION AND USAGE

Download the plugin from this link. Extract it directly in the Eclipse root directory. If you are using RAD, extract it in <RAD Install>\eclipse directory. This will create the com.webage.plugin.HeapView_1.0.0 directory under the plugins directory.

Start Eclipse or RAD. From the menubar select Windows->Show View->Other.

Expand Heap View and select Heap Values. Click on OK.

The view shows the following information.

  1. Heap size – The total size of the heap at this point.
  2. Memory used – The amount of heap that is currently in use to allocate objects.
  3. Heap maximum – The maximum size of the heap possible. The heap size can not grow beyond this point. This number will not change after Eclipse starts.

The values are refreshed every 5 seconds.

TUNING HEAP SETTINGS

First, let us find out how to configure the heap values. The heap size parameters can be supplied in the command line as shown below. For example:

eclipse.exe -vmargs -Xms176m -Xmx256m

This will set the initial heap size to 176MB and the maximum heap size to 256M.

For RAD, use the following command line:

rationalsdp.exe -vmargs -Xms176m  -Xmx1024m

To tune heap, first set a low initial heap size, say 10MB. Start Eclipse or RAD. Do basic development for a few minutes. Note the current heap size. In example below, the heap has grown from 10MB to 52MB.

If we start Eclipse or RAD using that much of initial heap size, there will be no need to grow the heap. This will improve performance.

Similarly, if you see that the heap size growing to a point too close the heap maximum, you are likely to run out of memory. Increase the heap size maximum in the command line to avoid the possibility of Eclipse or RAD behaving strangely due to an out of memory situation.