Skip to content

systemd: A process of this unit has been killed by the OOM killer

AItested on Ubuntu 24.04, systemd

Start, load, OOM kill, restart – every model server whose model does not fit into the allowed memory shows this pattern. Under systemd the proof is in the unit's journal, and the restart counter tells you how often it has happened.

Symptom

sudo journalctl -u llm-leak --no-pager -o cat | head -11
150 MB belegt
llm-leak.service: A process of this unit has been killed by the OOM killer.
llm-leak.service: Main process exited, code=killed, status=9/KILL
llm-leak.service: Failed with result 'oom-kill'.
llm-leak.service: Scheduled restart job, restart counter is at 1.

In the course the service llm-leak simulates a memory leak: it allocates 50 MB more every few seconds (“belegt” = allocated), the limit is 200 MB.

Diagnosis

The restart counter shows whether the service is stuck in a loop.

systemctl show llm-leak -p NRestarts
NRestarts=1

Causes

MemoryMax=200MThe need is above the limit

The service's cgroup may use at most 200 MB. With MemorySwapMax=0 there is no way out into swap – the kernel kills the process.

Restart=on-failuresystemd starts it again – and again

After every OOM kill systemd schedules a restart. If the model fundamentally does not fit into the limit, you get an endless loop like CrashLoopBackOff in Kubernetes.

Fix

Stop the service, set the limit to the measured need plus headroom or reduce the memory footprint (smaller model, quantization).
sudo systemctl stop llm-leak

Don't: Remove MemoryMax – then the kernel kills some arbitrary process on the host at the next shortage instead of just this service.

▶
Break it yourself and find it – free
Running LLM platforms hands-on, Day 1: Linux internals for AI services – cgroups, memory limits, OOM and restarts.
Go to day 1 →

FAQ

What is the same pattern called in Kubernetes?

OOMKilled with exit code 137, and CrashLoopBackOff for repeated crashes.

How do I set a memory limit without a unit file?

With systemd-run and -p MemoryMax=… you can start a command ad hoc in a limited unit.

Related error patterns

More