It’s common to get OutOfMemory while running heavy loaded application in Eclipse IDE. Recently while running Apache Tomcat under Eclipse for one of the web application I was getting Java Heap memory
related error java.lang.OutOfMemoryError
.
What needs to be done here basically is to increase the jvm heap size. So for increasing the JVM Heap Size of Tomcat in Eclipse we have to set few VM arguments of the tomcat.
Follow these simple steps to change the Heap Size of Tomcat under Eclipse. If you have below questions then you are at right place.
- Eclipse + Tomcat – java.lang.OutOfMemoryError
- How to increase tomcat memory inside eclipse
- Increase JVM max heap size for Eclipse
- java.lang.OutOfMemoryError: PermGen space in tomcat
- Configuration of the Eclipse Workspace
- How to set vm arguments in tomcat 8
Let’s get started
Step-1
- Open Eclipse IDE
- Go to Server Tab
- Add Apache Tomcat Servers to Eclipse IDE with detailed steps
- Double Click on Tomcat Server
Step-2
Click on “Open launch configuration” link.
Step-3
- Go to
Arguments
Tab and Add below parameter as per your need. -Xms512m -Xmx2048m
- Click Apply and OK
Or you could apply
-Xms1024m -Xmx3096m
Step-4
Start Tomcat Server
and look for log in Console Output- You should see tomcat server started with mentioned parameters
Extra Tips:
Following are few options available to change Heap Size.
-Xms<size> set initial Java heap size -Xmx<size> set maximum Java heap size -Xss<size> set java thread stack size
In addition, you could set minimum heap to 512MB
and maximum heap 2048MB
for any Java program let’s say sample – HelloWorld.
java -Xms512m -Xmx2048m HelloWorld