Eclipse Zone is brought to you in partnership with:

Alex is a Software Engineer working on Android development tools, especially Android Studio, at Google. His interests include Java, API design, OOP, IDEs and testing. Alex spends some of his spare time working on Open Source, blogging, writing technical articles, and speaking at international conferences. The opinions expressed here represent his own and not those of his employer. Alex is a DZone MVB and is not an employee of DZone and has posted 49 posts at DZone. You can read more from them at their website. View Full User Profile

OutOfMemoryError in Eclipse with JDK 1.6.0_21, on Windows

07.20.2010
| 21317 views |
  • submit to reddit

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:

-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
-product
org.eclipse.epp.package.java.product
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
-vm
D:\Java\jdk1.6.0_21\bin\javaw.exe
-vmargs
-Xms512m
-Xmx1024m
-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.

 

From http://alexruiz.developerblogs.com/?p=1377

Published at DZone with permission of Alex Ruiz, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Michal Huniewicz replied on Tue, 2010/07/20 - 4:43am

Alex, what does it mean exactly: "Eclipse was not setting the flag -XX:MaxPermSize, due to the change of vendor, from Sun to Oracle"?

Thanks for the article, I was getting the problem too; hope this will fix it.

Francisco Ceruti replied on Tue, 2010/07/20 - 5:14am

hahaha!!! i just spent a few hours trying to work this out. And when I finally got it right, 15 minutes later a new rss arrives to my reader. =D

Alex Ruiz replied on Tue, 2010/07/20 - 8:15am in response to: Michal Huniewicz

Hi Michal, According to Konstantin's blog: "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." Cheers, -Alex

James White replied on Tue, 2010/07/20 - 8:53am

We are still on Java 5 at work, but that's good to know though. Good article, thanks for posting.

Naiden Gochev replied on Tue, 2010/07/20 - 9:15am

I am running eclipse 3.6 with Java 1.6_21 I also have a lot of problems on my Windows XP 32bit machine with 3.5gb ram.

I am having all types of problems with all versions of eclipse mostly because the default config is total crap.

 anyway my current ini file looks like that and eclipse run very very very well.

-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
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
384m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms70m
-Xmx512m
-XX:+UnlockExperimentalVMOptions
-XX:+UseG1GC
-XX:MaxGCPauseMillis =100
-XX:GCPauseIntervalMillis =1000
-XX:+G1YoungGenSize=256m
-XX:+G1ParallelRSetUpdatingEnabled -XX:+G1ParallelRSetScanningEnabled
-XX:MaxPermSize=384m
-XX:PermSize=128m

 

I hope it helps to someone.

Paul Gregoire replied on Tue, 2010/07/20 - 10:44am

I pasted my config on dzone but I'll also paste it here in the hopes that i helps someone out. I have Windows 7 Pro x64 with 12 Gb of RAM.
-startup
plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.0.v20100503
-vm 
C:\Program Files\Java\jdk1.6.0_21\bin\javaw.exe
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
768m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms512m
-Xmx2048m
-Xss4m
-XX:PermSize=128m
-XX:MaxPermSize=384m
-XX:CompileThreshold=5
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UnlockExperimentalVMOptions
-XX:+UseG1GC

bruce wang replied on Tue, 2010/07/20 - 11:17am

Environment:
CPU: Intel(R) Core(TM)2 Duo CPU P8700
Memory: 3G
Win 7 + jdk-6u21-windows-i586 + eclipse-jee-helios-win32.

I have also experienced the same problem, eclipse frequent(minutes) crashes(OutOfMemoryError). Now my eclipse.ini file looks like that and eclipse run very well.

-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 -product org.eclipse.epp.package.jee.product --launcher.defaultAction openFile --launcher.XXMaxPermSize 256M -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256M --launcher.defaultAction openFile -vmargs -Dosgi.requiredJavaVersion=1.5 -Xms128M -Xmx512M -XX:PermSize=64M -XX:MaxPermSize=256M -XX:+UseParallelGC -XX:ParallelGCThreads=2

Michal Huniewicz replied on Tue, 2010/07/20 - 2:45pm in response to: Alex Ruiz

Oh, so that's a bug in the Eclipse launcher? Thanks for additional info.

Sandeep Khurana replied on Tue, 2010/07/20 - 11:04pm

An alternative approach is to use non-sun(non-oracle) jdk. It solved the issue for me.

Thomas Kern replied on Thu, 2012/09/06 - 11:01am

hi there,

I also got the same problem while using “myeclipse for spring 8.6 M2″. Since I’m a new user of myeclipse, I attributed that to myeclipse instead of JDK 1.6.0_21.

I changed my eclipse settings as well.

http://www.java-tips.org 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.