Memory leak: How to find whats causing it?

Since a few weeks my HA has a major problem with a memory leak.
HA container gets bigger an bigger over the day, until HA gets unresponsive.
At the moment my “solution” is to run a automation that restarts my HA every night.
I was never able to find the reason that is causing the memory leak.
Is there a way to solve this?
I run the latest version of HA and all installed extensions on a 4Gb Raspberry 4.

You could connect to the Pi and use “docker stats” to show you the current memory usage of each container. This would narrow it down to (probably) an add-on.

Note that you can’t use a terminal add-on to do this, as that runs in a container itself and does not have access to docker commands. If you don’t have the Pi connected to a monitor and keyboard, you can use SSH over port 22222 to connect, if this has been configured. This addon simplifies configuring the port.

Problem is, it is the Home Assistant container itself, that increases the memory.
Whats causing the problem inside is not visible for me.
I have attached a screenshot taken using glances.

Youll need to go in with docker exec -it homeassistant bash then run top, free or do other troubleshooting within the container. Your 4G of RAM is a bit low. You may need more.

Okay. Thanks for that. Tried top, and there is a Python process inside the HA container that seems to produce most of the load.

Hello!
Did you solve this problem?
Looks like I have the same…

Actually not.
My “solution” at the moment is, to restart the HA container daily at night, where no one / nothing is really using it.

Well my ha instance is currently using little less than 1 GB of ram. This is not concern for me as I have 20 gb. As I saw from your post you probably don’t use docker based installation. In docker you can easily manage mem and cpu consumption by containers. You can try to limit memory usage for this container in portainer but this is not permanent solution. It will wok till you restart ha. In my opinion only permanent solution will be to move to docker based installation on a normal pc.

I’m seeing a memory leak in Home Assistant OS 12.2 when running in Proxmox 8.2.2. At reboot, HAOS is using approximately 4 GB (out of 8 allotted), but it climbs over a few days. I first noticed it when I had the memory set to 4 GB and HAOS was crashing the overall environment.

Up until recently, it was running fine in 4 GB, but I got tired of it crashing and so bumped that up to 8. I hadn’t made any new configuration changes—only HAOS and Proxmox updates.

I have a similar setup with Proxmox and 8GB of memory. I noticed that if I do Developer -> Restart Home Assistant a couple of times the memory usage becomes near or at 8GB until I reboot the VM. Not sure if this information is useful for debugging.

Has a solution for this been found? I have haos installed in a vm on proxmox that I noticed the ram creeps up a little every day, just as described in this post

I am having the same problem. I had been using HAOS on an RPI 4 8GB. The fan died, so now I’m on a Dell Wyse 5070 with 8GB and no native storage drive. I had been running HAOS from an SSD, so just moved it over to the new box. I have only recently had reliability issues with Home Assistant, so is it caused by an update? Or have I done something wrong by moving the SDD from RPi to the Thin Client? I did Etcher for the new HAOS on the Thin Clent on the drive and restored a full backup to it. Problem is, I don’t know enough about the programming and troubleshooting to know what I don’t know?

I’m also suddenly having memory leaks and I don’t know why.
The only thing I did was installing a custom integration called “HASmartThermostat”. Maybe it causes the problem? I was on version 2024.10.3 and updated to 2024.10.4 in hopes that it will fix it. But now it crashed again (including all Addons). It rebooted itself after about 5 minutes.
Running HA OS on a RPi 4 with 4GB RAM on an SSD.

Edit: So far it has no longer crashed after I disabled two entities from an Zigbee2Mqtt motion sensor that were spamming the logs (about 2 entries every second) with warnings because those had invalid values (number out of valid range).

At least on my end it seems to be correlated to third party integrations. My advice would be disabling them all and adding them back one by one until you identify a culprit.
For me, it was the Wyoming Protocol integration that produced a memory leak. No matter how much RAM I allocated (up to 16GB in my proxmox setup), the memory always reached 95% utilization after a short period of time. By disabling the Wyoming Protocol integration, I was able to resolve the issue on my end. Now, my total memory consumption remains stable around ± 1GB.

1 Like

Hi … are you still running your HASmartThermostat’s? Are the still working? As of yesterday all of mine became “unavailable” and reports “This entity is no longer being provided by the smart_thermostat integration. If the entity is no longer in use, delete it in settings.”. Very odd, very annoying!

/Tonkin

Hi, sorry for the late response.
Yes, I’m still using SmartThermostat without further issues.

I still encountered crashes when compiling something in ESPHome. It is somewhat random. I’ve now switched to a dell optiplex micro pc with 12GB of RAM and there wasn’t a single crash since then.
But the RAM usage is still constantly increasing and I don’t know why.
I have lots of addons on my HA but according to the shown usages it is HA itself.
Maybe the 4GB of the RPi just aren’t enough anymore for my setup?