How to disable the oom killer on Linux?

My current configurations are:

> cat /proc/sys/vm/panic_on_oom 0 > cat /proc/sys/vm/oom_kill_allocating_task 0 > cat /proc/sys/vm/overcommit_memory 1 

but when I run the task, it will still be killed.

 > ./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 

Update

My tasks are used for scientific calculations that cost a lot of memories, it seems that overcommit_memory=1 may be the best choice.

Update 2

In fact, I am working on a data analysis project that costs more than 16G memory, but I was asked to limit it to approximately 5G . It would be impossible to implement this requirement by optimizing the program itself, since the project uses many subcommands, and most of them do not contain parameters such as Xms or Xms in Java.

Update 3

My project must be an excessive system. Be that as it may, a3f , it seems that my applications prefer xmalloc to crash when memory corruption fails.

 > cat /proc/sys/vm/overcommit_memory 2 > ./test/mem.sh ./test/mem.sh: xmalloc: .././subst.c:3542: cannot allocate 1073741825 bytes (4295237632 bytes allocated) 

I do not want to give up, although many scary tests make me exhausted. So please show me the way to the light; )

+5
source share
2 answers

The OOM killer will not go away. If there is no memory, someone has to pay. What you can do is set a limit after which a memory failure occurs. What is achieved from vm.overcommit_memory to 2 .

From the docs :

The Linux kernel supports the following overcommit processing modes.

2 - Do not recompile. The total address space for the system is not allowed to exceed swap + configurable amount (50% is used by default) of physical RAM. Depending on the amount that you use, in most situations this means that the process will not be killed during the access of the pages, but if necessary they will receive errors in the allocation of memory.

Typically, the kernel will happily distribute virtual memory (overcommit). Only when you link to a page does the kernel have to map the page to a real physical frame. If it cannot serve this request, the process must be killed by the OOM killer in order to free up space.

Disabling redirectors, for example, malloc(3) will return NULL if the kernel cannot fix the amount of requested memory. This makes things more predictable, albeit limited, (many applications highlight more than ever needed).

+8
source

Possible oom_adj values ​​range from -17 to +15. The higher the score, the greater the likelihood that the associated process will be killed by the OOM-killer. If oom_adj is set to -17, the process does not count for OOM killing.

But, ram ramping up is the best choice, if ram ramping up is not possible, then add swap memory.

To increase swap memory, try this link ,

+1
source

Source: https://habr.com/ru/post/1244415/


All Articles