Wednesday, July 21, 2010

OutOfMemoryError in Eclipse with JDK 1.6.0_21, on Windows

This past weekend I spent a good amount of time trying to solve an OutOfMemoryError that made Eclipse crash every 5 minutes. I’m running Eclipse Helios on JDK 1.6.0_21, with the following plug-ins: Subclipse, m2eclipse and Atlassian Eclipse Connector. It was hard to figure out which one was the troublemaker, since I installed everything in one shot on my new Windows laptop.

After a couple of hours of frustration, I finally found the solution in this post from Konstantin’s blog: Eclipse was not setting the flag -XX:MaxPermSize, due to the change of vendor, from Sun to Oracle, in JDK 1.6.0_21. This is a Windows-only issue. As Konstantin points out, the fix is simple: just add the missing flag (with the appropriate amount of memory) to the eclipse.ini file, just after the -vmvargs settings.

Here is my eclipse.ini:

01.-startup
02.plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
03.--launcher.library
04.plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.0.v20100503
05.-product
06.org.eclipse.epp.package.java.product
07.-showsplash
08.org.eclipse.platform
09.--launcher.defaultAction
10.openFile
11.-vm
12.D:\Java\jdk1.6.0_21\bin\javaw.exe
13.-vmargs
14.-Xms512m
15.-Xmx1024m
16.-XX:MaxPermSize=256m

Setting -XX:MaxPermSize to 512m (as Konstantin suggests) didn’t work for me. On my machine, Eclipse can only run if I set that flag to 256m.

For more details, including the bug number related to this issue, please visit Konstantin’s blog.

No comments:

Post a Comment