英文:
How to increase java heap size in docker container?
问题
我们在运行位于 Docker 容器中的 Selenium 测试时遇到了 Java 堆内存错误。我们尝试了传递 MAVEN_OPTS 和 JAVA_OPTS 来增加堆内存大小,但没有解决我们的问题。
docker run -e JAVA_OPTS='-Xmx3g -Xms3g' MAVEN_OPTS='-Xmx2048m' oneapi_docker mvn clean install
我们的错误信息:OutOfMemory Java 堆空间
我添加了一个日志记录器信息,以可视化运行测试时的内存消耗,但似乎没有受到影响。
- LoggerManager INFO : 可用内存:258 MB LoggerManager INFO : 已分配内存:404 MB
- LoggerManager INFO : 最大内存:498 MB LoggerManager INFO : 总可用内存:352 MB
- LoggerManager INFO : =================================================================```
我们的 Docker 文件如下:
```#步骤 0:选择基础镜像
FROM maven:latest
#步骤 1:安装先决条件
COPY . .
RUN mkdir -p /root/.m2 \
&& mkdir /root/.m2/repository
COPY settings.xml /root/.m2
ARG JAVA_OPTS
ARG MAVEN_OPTS
RUN echo $MAVEN_OPTS
RUN echo $JAVA_OPTS
(代码部分未翻译)
英文:
We are facing java heap error while running our selenium tests in docker container. We tried to pass MAVEN_OPTS and JAVA_OPTS to increase heap size but none of resolved our issue.
docker run -e JAVA_OPTS='-Xmx3g -Xms3g' MAVEN_OPTS='-Xmx2048m' oneapi_docker mvn clean install
> And our error message: OutOfMemory Java heap space
I just add a logger info to visualize memory consumption while running tests and seems that it was not affected.
- LoggerManager INFO : ========================== Memory Info ==========================
- LoggerManager INFO : Free memory: 258 MB LoggerManager INFO : Allocated memory: 404 MB
- LoggerManager INFO : Max memory: 498 MB LoggerManager INFO : Total free memory: 352 MB
- LoggerManager INFO : =================================================================
And our docker file like this;
#Step 0: Choose base
FROM maven:latest
#Step 1 : Install the pre-requisite
COPY . .
RUN mkdir -p /root/.m2 \
&& mkdir /root/.m2/repository
COPY settings.xml /root/.m2
ARG JAVA_OPTS
ARG MAVEN_OPTS
RUN echo $MAVEN_OPTS
RUN echo $JAVA_OPTS
答案1
得分: 0
你是如何执行Selenium测试的?如果是通过Surefire或Failsafe插件,你需要告诉它们你想增加堆大小。参考这个答案:https://stackoverflow.com/questions/4066424/java-lang-outofmemoryerror-java-heap-space-in-maven
英文:
How are you executing the Selenium tests? If via the Surefire or Failsafe plugins, you need to tell them you want to increase the heap size. See this answer: https://stackoverflow.com/questions/4066424/java-lang-outofmemoryerror-java-heap-space-in-maven
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论