Handling memory leaks in `homeassistant` container

Starting a few days ago I discovered a memory leak in the main homeassistant container. The main python process would balloon in RSS, consuming all memory & swap, triggering the OOM-killer.


Looking at the container logs, I saw one automation related to frigate, re-firing

2025-11-03 19:17:02.735 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Running automation actions
2025-11-03 19:17:02.735 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Executing step wait for trigger (timeout: 0:02:00)
2025-11-03 19:17:02.736 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Initialized trigger
2025-11-03 19:17:02.864 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Test condition template: False
2025-11-03 19:17:02.866 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeating sequence: Iteration 1110
2025-11-03 19:17:02.866 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Running automation actions
2025-11-03 19:17:02.867 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Executing step wait for trigger (timeout: 0:02:00)
2025-11-03 19:17:02.867 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Initialized trigger
2025-11-03 19:17:03.251 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Test condition template: False
2025-11-03 19:17:03.253 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeating sequence: Iteration 1111
2025-11-03 19:17:03.253 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Running automation actions
2025-11-03 19:17:03.254 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Executing step wait for trigger (timeout: 0:02:00)
2025-11-03 19:17:03.255 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Initialized trigger
2025-11-03 19:17:03.528 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Test condition template: False
2025-11-03 19:17:03.529 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeating sequence: Iteration 1112
2025-11-03 19:17:03.529 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Running automation actions
2025-11-03 19:17:03.529 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Executing step wait for trigger (timeout: 0:02:00)
2025-11-03 19:17:03.530 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Initialized trigger
2025-11-03 19:17:03.670 INFO (MainThread) [homeassistant.components.automation.porch_camera] porch camera: Repeat at step 2: Test condition template: False

The automation was actually unused, so I simply disabled it. I don’t know what’s made it problematic now as it has been unchanged for months (maybe something in a recent upgrade, but I can’t narrow it down to one off the top of my head).

My general question is, I wonder if there’s a better way to handle this class of problem.

  • Detect overly active automation? (e.g. One firing multiple times a second)
  • Detect automation is consuming too many resources? (The memory just being attributed to the python -m homeassistant sucks).
  • Detect oom killer activity, container restarts, etc.

My familiarly with managing linux systems meant I was both monitoring the system already, and could diagnose it quickly - but I was surprised homeassistant itself made no complaints about that was happening.

:astonished:

Set a limit (max:) for automations that use mode: queued or mode: parallel. That will generate a warning when the limit is exceeded. See: Automation modes - Home Assistant

Also set a timeout for your wait_for_trigger actions. See: Script Syntax - Home Assistant

This is not a memory leak is it?

Memory leak is accident of program
The program is doing exactly what it should here

1 Like