Eclipse Increase Memory Size - Crunchify.com

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 for Java7 and below JDK versions. For Java8, Java9 and Java10+ users, follow our latest tutorials Ideal eclipse.ini file setup for your Eclipse Environment.

Tuning Eclipse Performance and Avoiding OutOfMemory Exceptions

  1. Go to your Eclipse setup folder
  2. If you are running Eclipse on Mac OS X then
    • Right click on eclipse.app icon
    • Click on Show Package Contents
  3. Open eclipse.ini file
  4. Change below parameters
    1. -Xms512m
    2. -Xmx3000m (Hoping your developer box has >4GB of memory)
  5. Add below parameters
    1. -XX:PermSize=256m
    2. -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

Java 8 permanent generation memory settings are removed and no longer works

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.