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

前端 未结 11 772
野的像风
野的像风 2020-11-27 13:06

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.

Wh

11条回答
  •  有刺的猬
    2020-11-27 13:27

    First of all, I suggest that you narrow the problem to which component throws the "Out of Memory Exception".

    This could be:

    1. Eclipse itself (which I doubt)
    2. Your application under Tomcat

    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.

提交回复
热议问题