简体   繁体   English

Docker:在启​​用内存限制和禁用内存过量使用的情况下运行容器会有哪些负面影响?

[英]Docker: what are negative impacts of running container with memory limit enabled and memory overcommit disabled?

In my environment, I am going to disable the memory overcommit (vm.overcommit=2). 在我的环境中,我将禁用内存过量使用(vm.overcommit = 2)。 This disables Linux OOMKiller also. 这也会禁用Linux OOMKiller。

The reason is that I run Java apps in docker containers with properly memory size limitation and I want to see them failing with OOMError (and writing heap dump) instead of just killed silently by linux OOMKiller. 原因是我在具有适当内存大小限制的Docker容器中运行Java应用程序,我希望看到它们因OOMError(并写入堆转储)而失败,而不是被Linux OOMKiller静默杀死。

Iam not sure about possible negative impacts of that. 我不确定这样做可能带来的负面影响。 I am not a Linux kernel, docker memory management or Java VM expert, so decided to ask here. 我不是Linux内核,docker内存管理或Java VM专家,所以决定在这里询问。

If anyone has such experience, can you please tell me? 如果有人有这样的经验,您能告诉我吗?

If you disable memory overcommit, then if the JVM requests memory from the OS and all memory is committed, then the syscall will fail. 如果禁用内存过量使用,那么如果JVM向操作系统请求内存并且所有内存都已提交,则syscall将失败。 When that happens, the JVM to fail with an OOME and the message that includes "Out of swap space?". 发生这种情况时,JVM将失败,并显示OOME和包含“交换空间不足?”的消息。

My reading of the Oracle OOME troubleshooting documentation is that this will cause an fatal error logfile to be written. 对Oracle OOME故障排除文档的阅读是,这将导致写入致命错误日志文件。 It is not clear if a heap dump can be created. 尚不清楚是否可以创建堆转储。


If you are trying to track down a suspected memory leak, I would suggest setting the initial heap and max heap sizes to be the same value, and make them small enough that you don't get an "Out of swap space?" 如果您尝试查找可疑的内存泄漏,建议将初始堆大小和最大堆大小设置为相同的值,并使它们足够小,以免出现“交换空间不足?”的情况。 OOME. 天啊 If you get a "normal" OOME, you should be able to get a heap dump. 如果获得“正常”的OOME,则应该能够获得堆转储。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM