When trying to launch and run a flex/java project in eclipse I kept getting a "Out of Memory Exception" and "Java Heap Space" using Eclipse, Tomcat and a JRE.
While researching trying to adjust the memory settings I found three places to adjust these:
Eclipse.ini
The JRE Settings under Window > Preferences
Catalina.sh or Catalina.bat
What are the differences between setting -xms and -xmx in these different places and what does is mean?
Is there any way to verify these memory settings are being set accordingly?
What are the optimal -xms and -xmx settings for a computer with 2gb of RAM?
Any other memory tips?
Thanks.
OutOfMemoryError: Java heap space. 1) An easy way to solve OutOfMemoryError in java is to increase the maximum heap size by using JVM options "-Xmx512M", this will immediately solve your OutOfMemoryError.
Temporary fix – Increase the heap size On the Eclipse menu, clicks Run -> Run Configurations.. , select the Java application we want to run, click on the Arguments tab, VM arguments section, and adjust a better Java initial maximum heap size.
Increase Permgen Space in Eclipse If you are using below Java 8, then you might get OutOfMemoryError: Permgen space, just increase the permanent generation space available to Eclipse.
-xms is the start memory (at the VM start), -xmx is the maximum memory for the VM
First of all, I suggest that you narrow the problem to which component throws the "Out of Memory Exception".
This could be:
The JVM parameters -xms
and -xmx
represent the heap's "start memory" and the "maximum memory". Forget the "start memory". This is not going to help you now and you should only change this parameter if you're sure your app will consume this amount of memory rapidly.
In production, I think the only parameter that you can change is the -xmx
under the Catalina.sh or Catalina.bat files. But if you are testing your webapp directly from Eclipse with a configured debug environment of Tomcat, you can simply go to your "Debug Configurations" > "Apache Tomcat" > "Arguments" > "VM arguments" and set the -xmx
there.
As for the optimal -xmx
for 2gb, this depends a lot of your environment and the number of requests your app might take. I would try values from 500mb up to 1gb. Check your OS virtual memory "zone" limit and the limit of the JVM itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With