关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。
想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。
2年前关闭。
Improve this question
我目前的配置是:
> cat /proc/sys/vm/panic_on_oom
0
> cat /proc/sys/vm/oom_kill_allocating_task
0
> cat /proc/sys/vm/overcommit_memory
1
> ./test/mem.sh
Killed
> dmesg | tail -2
[24281.788131] Memory cgroup out of memory: Kill process 10565 (bash) score 1001 or sacrifice child
[24281.788133] Killed process 10565 (bash) total-vm:12601088kB, anon-rss:5242544kB, file-rss:64kB
overcommit_memory=1
可能是最好的选择。16G
,但我被要求将它们限制在大约 5G
.可能无法通过优化程序本身来实现这个需求,因为项目使用了很多子命令,而且大多数子命令不包含像Xms
这样的选项。或 Xmx
在 java 。xmalloc
崩溃当内存分配失败时。> cat /proc/sys/vm/overcommit_memory
2
> ./test/mem.sh
./test/mem.sh: xmalloc: .././subst.c:3542: cannot allocate 1073741825 bytes (4295237632 bytes allocated)
OOM 杀手不会消失。如果没有内存,就得有人付钱。您可以做的是设置一个限制,在此之后内存分配失败。
这正是设置vm.overcommit_memory
至 2
达到。
来自 the docs :
The Linux kernel supports the following overcommit handling modes
2 - Don't overcommit. The total address space commit for the system is not permitted to exceed swap + a configurable amount (default is 50%) of physical RAM. Depending on the amount you use, in most situations this means a process will not be killed while accessing pages but will receive errors on memory allocation as appropriate.
malloc(3)
将返回 NULL
如果内核无法提交请求的内存量。这使事情变得更加可预测,尽管有限(许多应用程序分配的比他们需要的更多)。
关于linux - 如何在 Linux 中禁用 oom 杀手?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35791416/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |