Eclipse will throw the below error when it runs out of memory. It normally occurs when performing memory-hungry operations on big projects such as building the project's workspace.

An internal error occurred during: "Building workspace".
GC overhead limit exceeded

Memory is allocated via Eclipse' configuration file, read and executed during Eclipse' startup. It is located in its installation directory and named eclipse.ini. The default values are good enough for small projects but might not suffice for the bigger ones.

Below is a sample 'eclipse.ini file;

-startup
plugins/org.eclipse.equinox.launcher_1.5.300.v20190213-1655.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.1000.v20190125-2016
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=1.8
-Dosgi.dataAreaRequiresExplicitInit=true
-Xms256m
-Xmx1024m
--add-modules=ALL-SYSTEM

Fixing the problem means allocating more memory for Eclipse. This could be done by increasing the values of these parameters in the configuration file where the numbers represent the amount of memory to be allocated in megabytes (MB):

-Xms256m
-Xmx1024m
Item Description
XmsInitial memory allocation pool
XmxMaximum memory allocation pool for Java Virtual Machine (JVM)

There's no magic number for the memory allocation as it depends on how big your project is and how much memory your system has. You can start by doubling the amounts as in the below example and then go from there, such as in the below example:

-Xms512m
-Xmx2048m

The changes will take effect after Eclipse is restarted.

Discuss the article:

Comment anonymously. Login not required.