Pages Navigation Menu

Coding is much easier than you think

How to increase JVM heap size in Eclipse

How to increase JVM heap size in Eclipse

To avoid getting java.lang.OutOfMemoryErrors, while running web application, we should increase heap size allocated by the JVM by using command line options.

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size
-Xss<size>        set java thread stack size


To do this, follow these steps:

1. Open the Server Configuration in Eclipse by double-clicking on the Server instance.

2. Click on “Open launch configuration” link
Increase JVM max heap size eclipse
3. Click on the Arguments tab and add the following command at the end of VM arguments: -Xms128m –Xmx1024m.
Increase JVM max heap size eclipse

These values may vary, depending on requirement/available memory

If you are not using any server, you can type the following on the command line before you run your program:

java -Xms64m -Xmx1024m MyProgram



  • Do not set -Xmx to too small value
  • Set -Xms to a small value

Setting -Xmx to small value mostly leads to OutOfMemoryErrors, because this is the maximum amount of memory you are allocating for Java and it cannot utilize memory beyond the set value.

Also If you set -Xms to higher value you might run out of memory. So try to keep it to a small value like -Xms16m.

About Mohaideen Jamil

I'm a Full stack developer of IT exp in J2EE, AngularJs, MicroServices, Docker, Spring (Boot, MVC, Cloud), Bluemix, DevOps. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

%d bloggers like this: