OOM killer, oomkiller

Source: Internet
Author: User

OOM killer, oomkiller
In Linux, there is an oom killer mechanism that enables selective kill of some processes when the system memory is exhausted. 1. Why OOM killer?
When we use an application, we need to apply for memory, that is, to perform the malloc operation. If a non-NULL operation is returned, the application has applied for available memory. In fact, there may be bugs in this place. Linux has a memory optimization mechanism, that is, it allows programs to apply for more memory than the available system memory, but Linux does not guarantee that the memory is available immediately, if the memory you applied for is not completely released when you need to use it, OOM killer will be triggered. The kernel code is mm/oom_kill.c. The Calling sequence is as follows:
Malloc-> _ alloc_pages-> out_of_memory ()-> select_bad_process ()-> badness ()
2. How to select the process to kill
Analyze the badness code. The selection process is as follows:
1) Calculate the memory occupied by the process and its subprocesses;
2) Calculate the CPU time and survival time
3) Adjust the weights accordingly.
In summary, the higher the memory usage, the higher the score, the higher the cpu time and survival time, the lower the score; the higher the process priority, the lower the score
Based on the above factors, a point value is obtained, and the highest score is selected and kill.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.