troubleshooting Linux & administration
Linux OOM selection and cgroup boundaries
A Linux workload can hit its cgroup memory limit while the host still has RAM. The OOM boundary tells you which processes could be selected; it does not tell you which one was killed.
What it means
Linux does not simply kill the process using the most RAM. When a memory allocation cannot be satisfied, the allocation context determines which processes are eligible for out-of-memory (OOM) selection. With the Linux cgroup v2 memory controller, a workload can reach its group's hard memory limit, memory.max, even when the host still has memory available. An OOM kill in that context cannot select a process outside the constrained group.
Reaching a limit and selecting a victim are separate events. The kernel may be able to reclaim memory, freeing enough for the allocation. If that succeeds, no OOM kill is needed for that allocation. If it does not, knowing the limit tells you where an OOM event could occur, not which process was killed.
Try it
Simulation: Start with OOM context set to cgroup, Reclaim to insufficient, Victim evidence to not-observed, and Required scenario evidence to provided. The result is candidate in the cgroup context. The possible victims are eligible tasks within the affected group; the example does not identify any particular task or establish that a kill occurred.
Linux OOM selection and cgroup boundaries
Distinguish memory pressure, cgroup max and OOM victim policy
OOM possible in selected context; exact victim not established.
Memory pressure
- Boundarycgroup
- Reclaiminsufficient
- Victim observationnot-observed
Conclusion
- Outcomecandidate
- Specific victimNot determined
This is a candidate boundary, not a victim selection algorithm. An observed victim flag never names the process.
Evaluated inputs
- Required scenario evidence
- provided
- Reclaim
- insufficient
- Victim evidence
- not-observed
- OOM context
- cgroup
Symbolic OOM context, no exact victim score, memory protection or actual process termination.
About this model
The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.
Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.
Change only Reclaim to sufficient. The group boundary stays the same, but the result becomes reclaimed: enough memory was freed in this example. The simulation does not evaluate Victim evidence on this path because it never reaches the selection question.
Use Reset to restore the four starting choices. Now switch only OOM context to global. The result is still candidate, but eligibility now depends on the global allocation context rather than the selected cgroup limit. Change Victim evidence to observed and the result becomes observed in the global context. It was the added evidence, not the change of scope, that established a victim in the example. No process is scored or terminated.
Which processes could have been selected?
Suppose a web worker runs inside a limited cgroup and a larger database process runs outside it. If the kernel invokes OOM handling within the worker's cgroup, the database is not a candidate for that event. Its size is irrelevant to that decision. The worker's membership makes it worth checking, but membership alone is not evidence that the worker was killed.
Even among eligible processes, resident set size (RSS) is not a victim-selection rule. RSS tells you about resident memory; the kernel's oom_score indicates relative likelihood of selection and can reflect a score adjustment. Neither value is a record of a kill. In a global event, do not reuse the local cgroup boundary, and do not assume every process on the host was eligible.
A known boundary is useful even when the outcome is unknown. With scenario evidence provided, setting Reclaim to unknown retains the selected context but leaves the reclaim question unanswered; victim evidence is not evaluated. Setting Required scenario evidence to missing is different: none of the context, reclaim, or victim choices is used to draw a conclusion.
With reclaim set to sufficient, a selected victim observation is not evaluated. With insufficient reclaim and no observed victim, the model describes the candidate scope, not the identity of a killed task. In a real investigation the event record and the applicable memory boundary must agree before associating an application restart with OOM selection.
In practice
If a worker disappears during a memory spike, start with the workload, its cgroup, and the time it disappeared. Do not exhaust memory to reproduce the event or change a limit to test a guess. Use existing, read-only evidence to distinguish these possibilities:
- Pressure without an established kill. Look at the affected cgroup's
memory.eventsaround the incident. Reclaim and throttling undermemory.highcan explain pressure without establishing that the kernel terminated the worker. - A cgroup limit. Check which group's
memory.maxapplied and whether the kernel report identifies a cgroup-local OOM event there. Host memory remaining available does not rule this out. To attribute the worker's disappearance to that event, look for a victim report that matches the worker and time. - A global OOM event. If the kernel report indicates a global event, use that context and its reported victim. A matching time alone does not show that the worker's cgroup limit caused the event.
If the only evidence is a pressure reading or a list of processes sorted by RSS, leave the cause of the disappearance unresolved. Stop before changing limits or selection policy if the event, its scope, or the applicable kernel and cgroup configuration are unclear. The boundary can rule a process out; to identify which process was actually killed, match victim evidence to the event.
Frequently asked questions
Editorial questions based on the listed sources and explicitly labeled local examples.
Does pressure always mean OOM?
No. Reclaim and throttling can occur without an OOM kill. Inspect the affected cgroup and kernel events before inferring that memory pressure caused termination.
Can a cgroup OOM differ from global OOM?
Yes. A cgroup memory limit may trigger OOM within a constrained group even when the host still has resources. Global memory failure has a different scope.
Is OOM victim deterministic from RSS alone?
No. A memory boundary and a large RSS reading are not enough to name a victim. The fixture can narrow scope or record a stipulated victim observation, but it does not enumerate candidates or compute selection scores.
What evidence should you inspect?
Actual memory events and kernel reports in the correct context.
Sources & model boundaries
Primary references used for this explanation. The interactive example is an educational model, not a live check.
- Linux Control Group v2
memory.max, memory.oom.group. Cgroup memory accounting, reclaim protection and OOM behavior have hierarchical scope. A cgroup-local OOM does not select tasks outside that cgroup.
Checked .
- proc_pid_oom_score(5)
DESCRIPTION. oom_score reports relative likelihood of selection, not guaranteed victim identity.
Checked .