Eclipse Memory Settings When Getting "Java Heap Space" and "Out of Memory"

Eclipse memory settings when getting Java Heap Space and Out of Memory

-xms is the start memory (at the VM start), -xmx is the maximum memory for the VM

  • eclipse.ini : the memory for the VM running eclipse
  • jre setting : the memory for java programs run from eclipse
  • catalina.sh : the memory for your tomcat server

java.lang.OutOfMemoryError: Java heap space in Eclipse, regardless of the settings

The eclipse.ini settings are only used for the Eclipse application.

When you Run a Java application from Eclipse you need to go to 'Run > Run Configurations'. Find your application in the Java application list. On the 'Arguments' tab enter your memory settings in the 'VM arguments' section.

Increasing heap space in Eclipse: (java.lang.OutOfMemoryError)

In Run->Run Configuration find the Name of the class you have been running, select it, click the Arguments tab then add:

-Xms512M -Xmx1524M

to the VM Arguments section

How to increase application heap size in Eclipse?

In the run configuration you want to customize (just click on it) open the tab Arguments and add -Xmx2048min the VM arguments section.
You might want to set the -Xms as well (small heap size).

Eclipse: Java heap space, How to fix it?

The memory usage depends on what do you do in the Eclipse and which plugins you have installed, but according to my experience 512Mb is not enough for comfortable work. I use for Eclipse Luna 64bit (eclipse.ini):

-Xms128m
-Xmx1200m

With these settings I can have Eclipse opened for a week with hundreds of source files opened without having OutOfMemoryError.

Note that PermSize/MaxPermSize option is obsolete since Java-8 (it does not actually change anything).

Can't solve Java heap space error in eclipse

Where is the "vmargs" option? If you set the min/max heap, you probably need to do it on the main process, not the launcher.

See the Eclipse FAQ item on setting VM options.

That launcher PermSize opt is a bit ridiculous. Unless you know it is launcher PermSize causing the OOM, keep it at the default of 256m.

[EDIT]

As pointed out else-thread, if this is happening when you run your Java program from Eclipse, you tweak those settings within the "Run Configuration" for that program, not Eclipse.ini.

Also, remember that you can tweak the VM options all you want, but if the program wants to eat all the resources on the box before it OOMs, no amount of tweaking can mitigate this.



Related Topics



Leave a reply



Submit