我已经在CircleCI(https://hub.docker.com/r/jiteshsojitra/docker-headless-vnc-container)中设置了运行自动化测试的工作,它工作正常,但在运行测试一小时后达到内存限制并突然杀死正在运行的Java / ant作业。那么有没有办法增加容器内存,所以测试可以在容器或其付费功能中运行5-6小时?
我尝试将- JAVA_OPTS: -Xms512m -Xmx1024m
放在YAML脚本中,但整体容器内存大小达到了~4GB。
https://circleci.com/gh/jiteshsojitra/zm-selenium/231
https://circleci.com/api/v1.1/project/github/jiteshsojitra/zm-selenium/231/output/106/0?file=true
BUILD FAILED
/headless/zm-selenium/build.xml:348: Java returned: 137
Total time: 76 minutes 26 seconds
Exited with code 137
Hint: Exit code 137 typically means the process is killed because it was running out of memory
Hint: Check if you can optimize the memory usage in your app
Hint: Max memory usage of this container is 4286337024
according to /sys/fs/cgroup/memory/memory.max_usage_in_bytes
答案 0 :(得分:2)
我们遇到了这个问题。 It is a limit in CircleCI (or the VM, really)。唯一的解决方案是让您的应用使用更少的内存。
答案 1 :(得分:0)
# set correct java startup
export _JAVA_OPTIONS="-Duser.home=$HOME -Xmx${JVM_HEAP_XMX}m"
# add docker jvm flags, can maybe removed with JDK9
export _JAVA_OPTIONS="$_JAVA_OPTIONS -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
现在,您可以将环境变量JVM_HEAP_XMX
设置为您的JVM应使用的兆字节数,例如
docker run -e JVM_HEAP_XMX=512 ...
如果要动态确定大小,请查看该脚本jvm_options.sh。