JAVA Memory and Docker

309 篇文章 0 订阅
JAVA Memory and Docker

Recently, I am working on a Java applications on ECS. It is a docker application running on the cluster.
But it keeps get killed by ECS agent. And the exception is saying, docker application is killed by memory usage.

Does that say my Java application have memory leak and go Out of Memory?

First, I checked my memory configuration on Java level. I am using -Xmx3G. My docker hard_limit and soft_limit are both 3G as well.

I am using spring framework, so I have the Perm Gen 256M.
So the VM may use memory like this: -Xmx3G + Perm Gen 256M + Other memory 217M + Xss per thread(Java Stack) = 3.5G

That might be why the ECS kill my docker applications.

Here are all the JVM exception list here
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html

>java \
-Xms2G -Xmx2G -XX:MaxMetaspaceSize=256M \
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="/tmp/dump_oom.hprof" \
-Dbuild.env=${RUNNING_ENV} \
-Drunning_module=${RUNNING_MODULE} \
-jar feeds-2g-1.0-jar-with-dependencies.jar 2>&1

I have my Java application running there for a while day, it is not saying any exception about memory. So that is 90% saying it is not Java OOM, it is use memory over the limit of hard_limit on ECS, and ECS agent killed my Java.

I adjust the configuration according to the ECS document.
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html

-Xms2G -Xmx2G and hard_limit and soft_limit 3G. Everything looks good after that.

Reference:
https://blogs.vmware.com/apps/2011/06/taking-a-closer-look-at-sizing-the-java-process.html
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值