Share via

How to fix Terminating due to java.lang.OutOfMemoryError: Java heap space error

Dhal, Sushreesmita 0 Reputation points
2024-01-30T13:31:45.9966667+00:00

My application is restarting multiple times with Terminating due to java.lang.OutOfMemoryError: Java heap space error. my configuration is like below , Please help on this

- name: JVM_OPTS
            value: -Xms5G -Xmx5G -XX:MaxMetaspaceSize=1024m -XX:ParallelGCThreads=16 -XX:+ExitOnOutOfMemoryError -javaagent:agent/applicationinsights-agent-3.4.12.jar   
Azure Container Instances
Azure
Azure

A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.

Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

3 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Q&A Assist
    2024-01-30T13:31:46+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To fix the java.lang.OutOfMemoryError: Java heap space error, you can increase the maximum heap size allocated to the JVM. In your current configuration, you have set the initial heap size and maximum heap size to 5GB using the -Xms and -Xmx JVM options. However, this may not be sufficient for your application's memory requirements.

    You can try increasing the maximum heap size to a higher value, such as 8GB or 10GB, and see if it resolves the issue. You can do this by modifying the -Xmx option in your configuration.

    - name: JVM_OPTS
      value: -Xms5G -Xmx10G -XX:MaxMetaspaceSize=1024m -XX:ParallelGCThreads=16 -XX:+ExitOnOutOfMemoryError -javaagent:agent/applicationinsights-agent-3.4.12.jar
    

    Keep in mind that setting the maximum heap size too high can also cause issues such as container OOM, so you need to find a balance between the memory requirements of your application and the available resources.


    References:

    0 comments No comments