Wednesday, July 14, 2010

Oracle JVM 6u21 and Eclipse

A number of users have encountered frequent Eclipse crashes since the recent Oracle JVM 6u21 update. The crash cause is listed as follows:

java.lang.OutOfMemoryError: PermGen space

The underlying problem if that in 6u21 (version 1.6.0_21), the vendor was changed from Sun to Oracle. Eclipse launcher reads the JVM vendor and if it detects a Sun JVM, it adds an extra –XX:MaxPermSize setting that is necessary for Eclipse to function. With the vendor change in 6u21, the launcher is no longer adding the necessary parameter on launch.

There is an Eclipse Platform bug open, but so far it doesn't look like there is going to be an attempt to resolve this until Helios SR1 scheduled for September.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=319514

Fortunately, there is an easy workaround. Open the eclipse.ini file in an editor. You will see something similar to this:

-startup
plugins/org.eclipse.equinox.launcher_1.1.0.v20100307.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.0.v20100307
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Xms40m
-Xmx384m

This is setting that's not having any effect after 6u21:

--launcher.XXMaxPermSize
256m

Remove it. In it's place, add -XX:MaxPermSize=256m on a new line after the -Xmx setting. Better yet, while you are in there, bump the memory limits to a higher value. Nothing ruins your train of thought better than your IDE crashing with an OutOfMemoryError. Here is a sample eclipse.ini that works on 6u21.

-startup
plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.0.v20100503
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
-vmargs
-Xms40m
-Xmx1024m
-XX:MaxPermSize=512m

IMPORTANT: I do work for Oracle, but this is not an official Oracle statement on this issue. Just some advice from one Eclipse developer to another.

Update: This problem is specific to Windows. On *nix variants, Eclipse launcher uses slower, but more robust logic for detecting JVM type. More information in Bug 320005 for those who are interested.

Update: Oracle has produced another build of 6u21 JVM that reverts the change that adversely affected Eclipse. If you have reverted back to an older JVM, you can safely move forward to 6u21. The build 1.6.0_21-b07 is safe to use. The version that Eclipse has trouble with is b06. You can check which version you have by running "java -version". More information in Sun Bug 6969236 for those who are interested.

9 comments:

SeuAndré said...

Thanks a lot for the tip!

This is a big thing, since java updates itself automatically and not every eclipse user is a "planet" reader or even aware of such link between eclipse start ups flags and the crash.

Tiran Kenja said...

Sadly it is pretty consistent that it seems impossible for the core Eclipse.org projects to release quick fixes for serious issues.

But at least those of us who subscribe to the rss feed know what is happening now. So thanks for that.

Zorbert said...

Thanks for that Info, although I knew that stuff before, because I run into that problem. Oracle should NOT do such changes in a minor release, wondering how they could do something like that: they should backport quickly.

I heard / read that this only impacts on Win-Platforms, is that true? And if yes: why?

@Tiran: a "Quick-Fix" does not help for eclipse 3.3, 3.4, 3.5, ok?

Anonymous said...

I am not sure who's problem this is. I hope this isn't a communication problem with the Eclipse team and Oracle. You would have thought that a simple (I am assuming a simple change) change such as this would have been communicated between the Eclipse team and Oracle. It's not as if Eclipse is a small IDE. The majority of Java developers have used and continue to use Eclipse at some point. Doesn't Oracle have an Eclipse plugin, Oracle Enterprise Pack for Eclipse, for development. Didn't they notice that Eclipse was crashing? Something's not adding up...

eclipsehowl said...

I like to name it Vendorgate ;-)

Anonymous said...

see Eclipse bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=319514

IceCubeR said...

it's the first issue in this faq:

http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F

on my win 7 pro i can't set 512mb
-XX:MaxPermSize=512m

but only 256 mb
-XX:MaxPermSize=256m

But.... did oracle really release a jvm without even try if eclipse runs on windows?!?!?

to be fair i read that on other os eclipse use a slower but more reliable method for identify jvm's vendor....
anyway... give a try before release!!!
Bye

Jordi said...

Thanks a lot for your tip, too. Me has salvado de muchos Dolores de cabeza

Anonymous said...

When I used
-Xmx1024m
-XX:MaxPermSize=512m
the loader crashed. (running on XP Pro SP 3)

But I was able to use
-Xmx512m
-XX:MaxPermSize=384m

Too soon to say whether this fixes the problem