core icon indicating copy to clipboard operation
core copied to clipboard

Home assistant memory leak

Open RadekLorenc opened this issue 1 year ago • 8 comments

The problem

After update to version 2024.8.0 and 2024.8.1 home assistant once started consumes bigger amount of memory in time line. At start RAM memory use is ~2,1GB, and after couple of hours increase to ~7 or more GB and VM killing process (python3) due to out of memory. Glance add-on show that most of the memory is consumed by "homeassistant" process but don't know what exactlly is going on.

What version of Home Assistant Core has the issue?

2024.8.1

What was the last working version of Home Assistant Core?

2024.7.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

455144157_8071964299550699_5583199392171712948_n Zrzut ekranu 2024-08-13 195358

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

RadekLorenc avatar Aug 13 '24 18:08 RadekLorenc

I can't confirm this. I am on the new version 2024.8.1 and I need about 2.5 GB without a steady growth.

mayrbenjamin92 avatar Aug 13 '24 21:08 mayrbenjamin92

Please try booting in safe mode and check if it persists

joostlek avatar Aug 13 '24 21:08 joostlek

After HA restart thru the night (8hours) RAM consumption raised up from 2.1GB to 6.4GB, hard disk drive spaceallocated to HA from 40% to 71% and medium CPU usage is about 75-80% thru all the night whitch never hapened before I'll try with safe mode. Screenshot_2024-08-14-05-26-41-63_c3a231c25ed346e59462e84656a70e50

RadekLorenc avatar Aug 14 '24 03:08 RadekLorenc

I can confirm, I have the same issue.. After Update, memory leak occurs randomly..

image

15:10 was update from 2024.7x - 2024.8.1 6 memory leaks, interresting that during night it was OK.

fraintt avatar Aug 15 '24 09:08 fraintt

Met the same situations, the memory usage always in growth

image

Currently in 2024.8.1, the usage drops only when I restarted ha core or docker

gonghao avatar Aug 16 '24 06:08 gonghao

I found same problem T T image

kinnoon123 avatar Aug 19 '24 13:08 kinnoon123

grafik

Unfortunately, I also have the same problem. Fortunately, I replaced the RPI two weeks ago. Instead of 2GB, it now has 4GB. Without the replacement, my HA would probably be full by now.

NordFreak avatar Sep 11 '24 18:09 NordFreak

I was running HA in Proxmox and watched memory usage rocket. Decides to install bare metal and still the same. I've had to setup an automation to restart HA Core Integration every 3 days. Is anyone looking into this memory leak we are experiencing?

glennwalsh avatar Sep 21 '24 17:09 glennwalsh

Having the same problem. I think it exist a few months, where HA kept going inresponsive. It got better since I edited templates that gave errors in the log, but still the memory usage grew. Today I dit a fresh install on Proxmox and also now the memory grows. Probably there is someting in the way HA treats the templates. I now have an automation that reboots HA when free memory gets below a limt. But this is not how it should work.

JanHermanS avatar Sep 23 '24 15:09 JanHermanS

I’ve been also having this issue. Solution right now is restart the node when memory usage is above 7gb. See proxmox graph:

IMG_9368

Samywamy10 avatar Sep 29 '24 08:09 Samywamy10

Update: Changed all templates. Mostly trigger based now. Memory use is still slowly growing. Graph shows 96 hours. You can see reboots. Mostly the reboots are for updates. I also made an automation ther reboots HA when memory is low. geheugengebruik HA

JanHermanS avatar Sep 29 '24 18:09 JanHermanS

Please follow the instruction at

Tracking down a memory leak of python objects

https://community.home-assistant.io/t/2024-5-tracking-down-instability-issues-caused-by-integrations/724441

bdraco avatar Sep 29 '24 18:09 bdraco

I'm seeing the same on 2 of 3 vm's running HA OS on Proxmox.

Production HA: image image

Test HA: image image

carlhye avatar Oct 23 '24 08:10 carlhye

It's crazy in my Mac, it consumes 98.58GB and the system warns me.

image

zenoven avatar Oct 29 '24 06:10 zenoven

i'm also experiencing this issue in a Docker instance on a Raspberry Pi 4 8gb. I've seen some threads relating this issue with Alexa Media Player addon but i don't have this and the issue occurs. I've starting to see this issue after upgrading to 2024.10.

thiagobucca avatar Oct 29 '24 22:10 thiagobucca

grafik

Unfortunately, I also have the same problem. Fortunately, I replaced the RPI two weeks ago. Instead of 2GB, it now has 4GB. Without the replacement, my HA would probably be full by now.

image

Everything has been ok for me again for some time, I didn't take any solutions, it went away on its own.

NordFreak avatar Oct 30 '24 03:10 NordFreak

Same issue but after upgrading to 2024.10.4. Reverting back to 2024.9.3 fixed the memory leaks. Tested with "Glances" addon. Container "HomeAssistant" is the one leaking on memory (~10MB per 5-10min).

ZTHawk avatar Nov 03 '24 21:11 ZTHawk

Upgrading to 2024.11.2 fixed my memory leaks

ZTHawk avatar Nov 21 '24 13:11 ZTHawk

Not for me. Still hungry for memory.

raphaeldias85 avatar Nov 21 '24 15:11 raphaeldias85

@RadekLorenc I had similar issues recently, and since removing the Zigbee2MQTT add-on from the HA, the python3 memory leak is no longer there. I migrated it to another docker host and it is even more responsive now.

image

alienatedsec avatar Nov 22 '24 16:11 alienatedsec

I've been suffering memory issues for the past couple of days. I've installed the Glances add-on and it seems Supervisor is the culprit - it's currently consuming half (15GB) of my total memory!

image

DJBenson avatar Nov 25 '24 01:11 DJBenson

@DJBenson :thinking:, anything in the Supervisor logs which might explain what is going on?

agners avatar Nov 25 '24 07:11 agners

@DJBenson :thinking:, anything in the Supervisor logs which might explain what is going on?

I don't I'm afraid. I spotted the issue at 00:30 and wanted to sleep so I just killed the Supervisor container and it seemed to sort itself out. That container hasn't used more than 256mb of memory today though.

I did notice that Supervisor was crashing every 10 minutes or so, maybe because of the memory leak or something else causing it but I was short of time as above so didn't dig deeper.

DJBenson avatar Nov 25 '24 22:11 DJBenson

For me, the problem has disappeared by itself. I did nothing except install the usual updates. But since then it's been quiet.

image

NordFreak avatar Nov 25 '24 22:11 NordFreak

I don't I'm afraid. I spotted the issue at 00:30 and wanted to sleep so I just killed the Supervisor container and it seemed to sort itself out. That container hasn't used more than 256mb of memory today though.

Yeah that sounds like normal level. If the issue comes back, please open an an issue in the Supervisor repository at https://github.com/home-assistant/supervisor along with the Supervisor logs.

agners avatar Nov 26 '24 08:11 agners

I still have no luck on this. I need to restart homeassistant time to time

~# free -m total used free shared buff/cache available Mem: 15770 10335 214 12 5251 5435 Swap: 975 542 433

~# ps aux --sort=-%mem | head -n 11 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 433643 3.9 54.8 11717368 8863936 ? Ssl Nov24 119:35 python3 -m homeassistant --config /config root 81336 0.3 1.0 481116 173308 ? Ssl Nov21 23:07 python3 -m supervisor root 89378 2.0 1.0 21435104 164252 ? Sl Nov21 140:43 node-red root 81683 1.1 0.7 11240824 127108 ? Sl Nov21 77:10 node index.js root 638584 0.0 0.7 441232 123364 ? Ssl Nov25 0:21 /usr/local/bin/python3.12 /usr/local/bin/matter-server --storage-path /data --port 5580 --log-level info --log-level-sdk error --primary-interface enp2s0 --paa-root-cert-dir /data/credentials --ota-provider-dir /config/updates --fabricid 2 --vendorid 4939 --listen-address 172.30.32.1 root 581603 0.0 0.7 11227644 113144 ? Sl Nov25 0:32 node index.js root 300607 0.6 0.6 11224996 112892 ? Sl Nov23 27:38 node index.js root 279 0.0 0.5 135912 93636 ? Ss Nov20 3:54 /lib/systemd/systemd-journald root 793 0.6 0.4 3523640 78212 ? Ssl Nov20 49:18 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock root 2797 0.2 0.3 1502964 56640 ? Ssl Nov20 21:24 mosquitto -c /etc/mosquitto/mosquitto.conf

raphaeldias85 avatar Nov 26 '24 13:11 raphaeldias85

Same issue here, and the strangest think it's the issue started 5 days ago by itself (I haven't done any update in the last 10 days).

Screenshot_20241130_172351_Home Assistant

Homeassistant container is the one consuming the memory:

image

I tried to update HA core today but didn't fix the issue.

heisenberg2980 avatar Nov 30 '24 13:11 heisenberg2980

Same here, i have a basic setup in Proxmox with Zwave and my memory use keep growing over about 4 days........... a reboot of HA does not fix it, only rebooting the VM will reset it.

You can see the reboot in the graph, then the steady climbing memory use

image

dasher7320 avatar Dec 14 '24 13:12 dasher7320

@dasher7320 looking at the memory reported by Proxmox is not a very accurate method of checking the memory used, as a VM will typically reserve all the memory assigned to it, but that doesn´t mean the memory is actually being used. A better method is checking the memory reported by Home Assistant (rr use the integration "System Monitor" that creates multiple sensors, including the memory used: https://www.home-assistant.io/integrations/systemmonitor)

image

heisenberg2980 avatar Dec 14 '24 14:12 heisenberg2980

@heisenberg2980 Thanks for the tip, i have added the stats and yes the memory use on Proxmox is currently 3.08 of 4gb, yet HASS is showing 925mb (23%) so who know why it is so different..............

dasher7320 avatar Dec 15 '24 00:12 dasher7320