OutOfMemoryError in Eclipse | Java Virtual Machine (JVM)

OutOfMemoryError in Eclipse | Java Virtual Machine (JVM)

It might happen that while running a Java application within the Eclipse environment you get an OutOfMemoryError due to the maximum amount of memory dedicated to the heap. You can fix it by increasing the minimum (-Xms parameter) and maximum (-Xmx parameter) heap size. You can do it in two different ways:

1. By editing your eclipse.ini file you find under your Eclipse installation directory. Within that file you should find two lines similar to the following ones:

-Xms40m
-Xmx512m

You might want to change them depending on your hardware. For example I changed them as follows:

-Xms256m
-Xmx1024m

It means: “start with an initial heap size of 256 MB and grow to a maximum of 1024MB, that is 1GB.”

2. By editing the Run Configurations in Eclipse. To do this, right-click on the class you want to run (the one with the main method) and then select:

Run As -> Run Configurations

Click on the Arguments tab. In the VM Arguments box type:

-Xms256m -Xmx1024m

or whatever you prefer, depending on the hardware you possess.

IMPORTANT NOTE: It is strongly recommended that you make a backup copy of your eclipse.ini file before editing it in any way.

This entry was posted in IT, Programming and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

3,535 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>