java Maven 失败并出现错误“进程以代码 137 退出”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36218635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven fails with error 'Process exited with code 137'
提问by Mykhaylo Adamovych
Maven fails with scarce 'Process exited with code 137' in logs.
What could be possible reasons of the error and what could be the fix?
Maven 失败,日志中缺少“进程退出,代码为 137”。
错误的可能原因是什么,修复方法是什么?
回答by Mykhaylo Adamovych
Process was killed by Linux OOM Killerbecause you are low on resources on the machine.
进程被Linux OOM Killer杀死,因为您机器上的资源不足。
Give machine more memory and/or swap or reduce memory footprint of your process which is directly impactedby jvm default Xmx, which most probably is far from what jvm actually uses.
为机器提供更多内存和/或交换或减少进程的内存占用,这直接受到jvm 默认 Xmx 的影响,这很可能与 jvm 实际使用的相去甚远。
Give it additional java command line options
给它额外的 java 命令行选项
-Xmx256m -XX:MaxPermSize=512m
or configure system variable
或配置系统变量
MAVEN_OPTS=-Xmx256m -XX:MaxPermSize=512m
MaxPermSize have no use for java 8+
MaxPermSize 对 java 8+ 没有用
回答by Adam Burley
Just to note, I eventually found that the problem was too much memory being allocated, not too little.
请注意,我最终发现问题是分配的内存太多,而不是太少。
When running the job on a machine with 2GB of memory and setting the max heap size to 2GB, the build eventually failed with status 137. However when setting the job to 1GB maximum (e.g. -Xmx1g -Xms512m
), the build succeeded.
在具有 2GB 内存的机器上运行作业并将最大堆大小设置为 2GB 时,构建最终失败,状态为 137。但是,当将作业设置为最大 1GB(例如-Xmx1g -Xms512m
)时,构建成功。
This kind of makes sense, because the JVM will freely increase its memory up to the maximum heap size, but if there's not enough real memory, the OS will kill the process. However, if you reduce the max heap size, the JVM won't try to increase its memory so highly, so the OS won't worry about it enough to kill it.
这是有道理的,因为 JVM 会自由地将其内存增加到最大堆大小,但是如果实际内存不足,操作系统将终止该进程。但是,如果您减少最大堆大小,JVM 不会尝试将其内存增加得如此之大,因此操作系统不会担心它足以杀死它。
Furthermore, I was using GWT which forks a separate process for compilation, and the arguments have to be specified as an extraJvmArgs
element within gwt-maven-plugin
configuration, not in MAVEN_OPTS
.
此外,我使用的 GWT 分叉了一个单独的编译过程,并且必须将参数指定为配置中的extraJvmArgs
元素gwt-maven-plugin
,而不是MAVEN_OPTS
.