关闭。这个问题不满足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 可能是最好的选择。
更新 2
实际上,我正在做一个数据分析项目,它的内存消耗超过16G ,但我被要求将它们限制在大约 5G .可能无法通过优化程序本身来实现这个需求,因为项目使用了很多子命令,而且大多数子命令不包含像Xms 这样的选项。或 Xmx 在 java 。
更新 3
My project应该是一个过度使用的系统。究竟是什么a3f说,似乎我的应用程序更喜欢通过 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)
我不想投降,虽然这么多可怕的考验让我筋疲力尽。 所以请给我一条通向光明的道路; )
Best Answer-推荐答案
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.
通常,内核会很乐意分发虚拟内存(过量使用)。只有当你引用一个页面时,内核才必须将该页面映射到一个真实的物理帧。如果它无法为该请求提供服务,则需要由 OOM 杀手杀死一个进程以腾出空间。
禁用过量使用意味着例如malloc(3) 将返回 NULL 如果内核无法提交请求的内存量。这使事情变得更加可预测,尽管有限(许多应用程序分配的比他们需要的更多)。
关于linux - 如何在 Linux 中禁用 oom 杀手?,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/35791416/
|