Are you running heavy Java projects in Eclipse?
Is garbage collection happening too fast? Eclipse is consuming lots of CPU or Memory resource? In my case, while running Eclipse project, I recently got Out Of Memory (OOM) error.
There are some simple tuning required in order to fix it. Below hack worked for me.
NOTE:
This tutorial works very well forJava7
and below JDK versions. ForJava8, Java9 and Java10+
users, follow our latest tutorials Ideal eclipse.ini file setup for your Eclipse Environment.
Tuning Eclipse Performance and Avoiding OutOfMemory Exceptions
- Go to your Eclipse setup folder
- If you are running Eclipse on Mac OS X then
- Right click on
eclipse.app
icon - Click on
Show Package Contents
- Right click on
- Open
eclipse.ini
file - Change below parameters
- -Xms512m
- -Xmx3000m (Hoping your developer box has >4GB of memory)
- Add below parameters
- -XX:PermSize=256m
- -XX:MaxPermSize=512m
Also, if you are running Eclipse from command prompt, use below parameters:
C:\Program Files\eclipse\eclipse.exe -vmargs -Xmx2400m -Xms1024m -XX:PermSize=256m -XX:MaxPermSize=512m
-XX:PermSize specifies the initial size that will be allocated during startup of the JVM. If necessary, the JVM will allocate up to -XX:MaxPermSize.
Starting Java 8 permanent generation memory settings are removed and no longer works. The Permanent Generation (PermGen) space has completely been removed and is kind of replaced by a new space called Metaspace
.
Metaspace takes advantage of Java Language Specification property : Classes and associated metadata lifetimes match class loader’s
This is what my eclipse.ini file looks like:
-startup ../Eclipse/plugins/org.eclipse.equinox.launcher_1.6.0.v20200915-1508.jar --launcher.library ../Eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.2.0.v20200915-1442 -product org.eclipse.epp.package.jee.product -showsplash org.eclipse.epp.package.common --launcher.defaultAction openFile --launcher.defaultAction openFile --launcher.appendVmargs -vmargs -Xss128m -Xmn1024m -Declipse.p2.max.threads=10 -Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest -Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/ -Dosgi.requiredJavaVersion=11 -Dosgi.instance.area.default=@user.home/eclipse-workspace -Dsun.java.command=Eclipse -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Dosgi.requiredJavaVersion=11 -Dosgi.dataAreaRequiresExplicitInit=true -Xms1024m -Xmx3024m --add-modules=ALL-SYSTEM -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
If you have any other Eclipse optimization steps then please share and we will update our tutorial.
The post How to Increase Eclipse Memory Size to avoid OutOfMemory (OOM) on Startup – Java Heap Space appeared first on Crunchify.
0 Commentaires