Saturday, June 21, 2014

9:45 PM

Good day!


I ran into a problem while building worskpace on a big project in Java, Eclipse will throw GC overhead limit exceeded. It seems that it runs out of memory, the error would look something like this:

An internal error occurred during: "Building workspace".
GC overhead limit exceeded

So I tweak my eclipse IDE to show the garbage collector the “Show Heap Status”. To enable this feature browse Eclipse -> Window -> Preferences General. Then check the "Show heap status" after that click "OK" you will see the Eclipse memory heap status in the bottom right corner of your workbench.

My heap was at 112MB when I click the Run Garbage Collector (Garbage icon) on the heap status it went down into 68MB. Pretty helpful that you know the heapsize and you can force to garbage collect it to avoid crash or Java heap space.

Below is the screenshot that contains the checkbox in addition to the actual widgets it enables.
 



Sometimes I wonder why this preference is not a default checked to make simple things better?

Additional tweak I made is to allocate more memory in my Eclipse instance. To do this, locate eclipse.ini file in your Eclipse installation directory. The content would be similar to the following:

$ vim eclipse.ini
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.1.200.v20140116-2212
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m
 To increase memory allocation for your Eclipse instance, edit the number's in the following lines accordingly. The amount is the number of Megabytes in memory.
-XX:MaxPermSize=1024m
-Xms512m
-Xmx1024m

MaxPermSize defines the memory allocated to keep compiled class files.
Xms specifies the initial memory allocation pool
Xmx spcifies the maximum memory allocation pool for the Java Virtual Machine(JVM)

Restart your Eclipse IDE to take effect of the changes.

- End -

0 comments:

Post a Comment