什么是 Out of Memory 信息:牺牲孩子?

Mar*_*ark 26 linux-kernel out-of-memory

我的计算机最近内存不足(在处理大型 GIS 数据集时编译软件的意外后果)。在详细说明它如何处理 OOM 条件的系统日志中,有以下行:

Out of memory: Kill process 7429 (java) score 259 or sacrifice child
Run Code Online (Sandbox Code Playgroud)

那是or sacrifice child关于什么的?肯定不是在考虑一些黑暗的仪式来让事情继续下去吗?

小智 12

我从源文件中找到oom_kill.c,OOM Killer,在将此类消息写入系统日志后,检查已识别进程的子进程,并评估是否可能杀死其中一个进程来代替进程本身。

这里从源文件中提取的注释解释了这一点:

/*
 * If any of p's children has a different mm and is eligible for kill,
 * the one with the highest oom_badness() score is sacrificed for its
 * parent.  This attempts to lose the minimal amount of work done while
 * still freeing memory.
 */
Run Code Online (Sandbox Code Playgroud)