How does the OOM-Killer select a task to kill?

 

How does the OOM-Killer select a task to kill?

 SOLUTION 已验证 - 已更新 2017年二月28日16:41 - 

English 

环境

  • Red Hat Enterprise Linux ( All version)

问题

  • How does the OOM-Killer select a task to kill?

决议

When a system runs out of memory and OOM-killer is needed to set memory free in order to allow new memory allocations, any process in the system's task list is a candidate to be killed. This does not necessarily mean that the process which has the biggest virtual memory area will be a direct first hit, however it has its chances of being killed as well.

When the routine OOM-killer is called, it iterates over the task list calculating a score, called 'badness', for each process enlisted there. In its context the badness calculator utilizes a fairly simple formula that tries to select the better task to kill in a system following this logic:

  1. try to lose the minimum amount of work done;
  2. permit to recover a large amount of memory;
  3. try to not kill anything innocent of allocating large amount of memory;
  4. try to kill the minimum amount of tasks at a time (one process is always the goal);
  5. try to kill what end-users expect the kernel should kill;

When OOM-killer is calculating a given process badness, the first thing taken into account is the process total virtual memory size (vm), in pages, and this number will serve as the base for all further OOM-killer 'badness' score calculations. While one might think that processes which have big "vms" are prone to be first selected by OOM-killer, the calculations also take into consideration other data to adjust a process score, thus giving to it a chance of not being killed even if it is the biggest memory allocator in the box.

Below, these are other things that will adjust a process 'badness' score:

  • Forked childs: for each child which has its own 'vm', a half of that vm is accounted to a task points score;
  • CPU time: a task gets its score reduced by a factor rendered from the integer part of the square root of its CPU running time. So last longing tasks or tasks runing often are adjusted to score less, even if they are allocating big chunks of memory;
  • Niced processes: a niced process is considered less important, so they get their score doubled;
  • Superuser processes: As they are usually considered more important, they get their score reduced by a factor of 4;
  • External adjustment: System administrator can do external adjustments to this calculations, in order to prevent oom-killer to kill an undesirable process which otherwise would be killed in a memory shortage.

Further information on OOM-Killer:

标题基于Spring Boot的骑行路线规划与分享平台研究AI更换标题第1章引言介绍骑行路线规划与分享平台的研究背景、意义、国内外现状以及本论文的方法和创新点。1.1研究背景与意义分析骑行运动普及和路线分享需求,阐述平台设计的必要性。1.2国内外研究现状概述国内外在骑行路线规划与分享方面的技术发展和应用现状。1.3研究方法与创新点说明本文采用的研究方法和实现的创新功能。第2章相关理论与技术介绍Spring Boot框架、路线规划算法和分享技术的基础理论。2.1Spring Boot框架概述解释Spring Boot的核心概念和优势,以及在本平台中的应用。2.2路线规划算法原理阐述常用的路线规划算法,如Dijkstra、A等,并分析其适用场景。2.3分享技术实现方式介绍平台实现路线分享所采用的技术手段,如社交媒体集成、二维码生成等。第3章平台需求分析与设计详细阐述骑行路线规划与分享平台的需求分析、系统设计和数据库设计。3.1需求分析从用户角度出发,分析平台应具备的功能和性能要求。3.2系统设计设计平台的整体架构、模块划分以及各模块之间的交互方式。3.3数据库设计根据平台需求,设计合理的数据库表结构和数据存取方式。第4章平台实现与测试说明平台的开发环境、关键模块的实现过程,以及系统测试的方法与结果。4.1开发环境搭建介绍开发平台所需的软硬件环境及其配置方法。4.2关键模块实现详细描述路线规划、路线分享等核心功能的实现细节。4.3系统测试与性能评估对平台进行功能测试、性能测试,并分析结果以验证系统的稳定性和可靠性。第5章结论与展望总结本文的研究成果,指出不足之处,并展望未来的研究方向和改进措施。5.1研究结论概括性地阐述本文的主要研究内容和取得的成果。5.2未来工作展望针对当前研究的局限性,提出未来可能的改进方向和扩展功能。
Docker提供了一个选项来设置容器不被操作系统杀死,该选项称为"oom-kill-disable"。oom-kill-disable是一个用于禁用内存超限时杀死容器的选项。 当容器内存使用量超出其可用内存的限制时,操作系统会触发一个内存超限(OOM)事件。通常情况下,为了从OOM事件中恢复,操作系统会选择杀死占用内存较大的进程(包括容器)来释放内存资源。 如果我们想禁止Docker容器在OOM事件中被杀死,我们可以使用"oom-kill-disable"选项。这个选项可以在运行容器时通过命令行或Docker Compose文件进行设置,具体的使用方法如下: 1. 在使用命令行运行容器时,添加"--oom-kill-disable"选项,例如: ``` docker run --oom-kill-disable <容器名称或ID> ``` 2. 在Docker Compose文件中,为容器配置"oom_kill_disable"字段并设置为true,例如: ```yaml services: myservice: oom_kill_disable: true ``` 注意,禁用容器的OOM事件可能导致主机操作系统的整体性能下降,甚至会影响到其他容器的正常运行。因此,在使用"oom-kill-disable"选项时需要仔细评估容器内存使用及主机资源的情况,确保系统的稳定性和可用性。 最后,需要注意的是,对于大多数情况来说,允许操作系统根据OOM事件决定杀死容器是合理的做法,因为这有助于保持系统的可用性和可靠性,并防止整个系统由于单个容器的内存消耗过大而崩溃。所以,在设置"oom-kill-disable"选项时,需要慎重考虑。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值