Improving Performance of Eclipse on OS X Leopard by Increasing Max Memory for Heap

My PowerBook G4 1.25Ghz just isn’t the performance king it was 4 years ago (ok, the G4 never was a performance king). This became clearly evident when I launched a recent version of Eclipse and attempted to work on a small of project.

Text entry in the editor screen lags, content menus which should appear instantly on right click are 3 or more seconds delayed, and on…  So, I did what every red-blooded American techie has ingrained in his skull–I threw money at the machine.  First I added more memory, from a mere 512Mb to 1.25Gb.  No appreciable performance gain in Eclipse performance, but other programs performed happier (read faster) while Eclipse was running .  Next, since my meager 40Gb 4200rpm IDE drive was getting filled anyhow, I bought a brand new 160Gb 5400rpm drive.  My system began booting faster, and the average start-up time for Eclipse decreased slightly, but once again little or no performance improvement.  It got so bad that I began using Jedit as my primary IDE for a while, convinced that there was no way my little G4 could muster the umph to give me a satisfactory Eclipse experience.

Then, enlightenment.

At a local PHP meetup in Boston, someone suggested that since Eclipse was a java based program, the max memory may be getting set somewhere, thus forcing more swapping then needed.  After a little research, I discovered where the setting reside.  Eclipse has a configuration file (

eclipse.ini

) which contols the minimum and maximum size of the heap.  If you’re using a OS X based Eclipse you’ll find this file by showing the content of Eclipse.app by right clicking

 (Ctrl+click)

on the file and selecting show package contents.  The file is located in

Contents/MacOs/

.

Look for the following lines:

-Xms40m
-Xmx256m
-XX:MaxPermSize=256m
Xms

and

Xmx

set the minimum and maximum heap size. 

 The XX:MaxPermSize

is a bit confusing, but one thing it can affect is Garbage collection.  The part of the heap that

MaxPermSize

defines is where classes and methods are kept and if it fills, it can trigger a full garbage collection.   I found some discussion online about what this setting means for memory usage and how different versions of Java apply these settings diffently. Base on my cursory exploration, you can be safe by using this formula to determine the maximum memory Eclipse will use:

 Xmx + XX:MaxPermSize

This all in mind, I set mine at:

-Xms256m
-Xmx512m
-XX:MaxPermSize=256m

Like magic, Eclipse began running significantly better.  As a note, I run a pretty light system with usually only a few applications and servers going, so this may not be the way to go if you’ve got OpenOffice and GIMP going while working in Eclipse (unless you have 4Gb of free ram that is…).

Good Luck!

UPDATE: A friend indicated the performance increase noticed by me may not be as huge for those with newer, multi-core systems as garbage collection can be handle by a second processor.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>