Home Assistant - High Memory Usage

I’m not sure if there is still a memory leak but without a doubt the recent releases require a lot mor RAM!

I’ve finally resolved my memory related crashing recently … My VM used to run wonderfully in v107 before updating to v110 and now v111. But with v110 it started crashing every several hours consistently — I have a notification for every restart.

But I didn’t know why until several days of researching finally helped me find the python out-of-memory exceptions in the log showing that the process was being killed due to memory constraint.

I had never needed more than 300-400MB RAM allocation, so my VM was allocated 512MB without issue, but now I’ve seen the new versions jump to a little over 1GB (especially I when working the Lovelace UI editor), and has averaged 650-700MB consistently now (see chart below).

I thought it was a v110 issue so I’ve already updated to v111.4. The memory consumption still climbs up, but I’ve definitely seen it drop and recover some. Since I’ve updated my VM allocation now to 2GB my restarts have stopped completely. And you can see how there are memory recoveries in the chart below.

Just thought I’d share my recent memory issues in case this helps anyone else.

Are you using any addons? If so have a look at them first. The Glances addon is good for that.

I’m seeing a pretty constant overall use of 1.3GB overall and the Homeassistant container using about 1GB. I’ve been recording data for 30 days.

Same (or similar) issue here. The mem climes up and eventually freezes the RPI3B+ (nowadays takes roughly 1 day only!). I have a script that reboots the PI when mem is above 90% but this is not how it should be. Everything used to run fine until a week or so ago; the whole setup is kinda stable (config not changed, no new addons, etc.) so I guess it has to do with either updating the host SW, Hassio or one of the addons.

I’m not using many add-ons, just samba shares, configurator, and check HA config (for detecting breaking change issues to my config).

Otherwise I much rather run everything else as separate dockers on my Unraid server (MariaDB, InfluxDB, etc).

The memory has stabilized pretty well at ~680-700MB, with the DB now connecting to separate MariaDB docker server)… and not a single auto-reboot since increasing the allocation of my VM from 512MB up to 2GB (1GB initial).

If I’m using Lovelace editor a lot it will climb on up above 1GB, but eventually drops. Overall, HA just needs more RAM since 110.

The 1GB of RAM afforded on the R-Pi 3-b just won’t cut it anymore…this is yet another reason I’m super happy that I migrated from my dying RPi 3 over into a VM on Unraid!

I’m getting the same issue on 0.112.

It was never a problem, as it didn’t lock the thing up completely, but on this release it slams the CPU as well as the RAM (before it was generally just RAM), locking the VM up completely.

I’m running on proxmox with the guest agent enabled.

If you have cpu usage maxing out (90%+), please post a py-spy recording with a 360 duration.

I haven’t noticed mine getting into 90%+, but it is definitely still all over the place and many automations and the dashboard in general have become unreliably slow or just don’t even happen at all. I’ve also just given up on logging into HA’s dashboard for the most part, but I have noticed on several occasions that influx, grafana, or nodered are simply not running anymore and need to be started back up. So my graph below isn’t showing everything.

It’s gotten to the point that I’ve gone from showing off HA every chance I got, both in dashboard and demoing automations to people- to shying away from even mentioning using any automation in the house. It’s really frustrating and disenchanting.

I’m running on a Pi 3 B+ with Supervisor. How do I go about installing and running py-spy correctly in this setup?

You’ll need to run it inside the container

Hello everyone,

recently updated to version 0.112.4. With this version the crashes have started. To the HW:

  • Raspberry Pi 4 with 4GB with SSD (productive system)
  • Raspberry Pi 3B for Maria DB with USB stick (trial version)

The only new message in the log is:

2020-07-20 22:08:59 ERROR (MainThread) [homeassistant.components.discovery] Network is unreachable

Every 12 hours the RAM increases to >90%. The system reacts slowly. I have now created a node-red flow which reboots the host system at 90% RAM usage. It is always the container “homeassistant”. Pictures of this: (glances RAM)

chrome_JaBFcGx9m8

I will now try from @bdraco the idea for troubleshooting. Is it a general problem or am I looking for something only in my config?

It’s probably a bug in one of the integrations you are using. The py-spy might help point to the cause. If not, disabling one each day until the problem goes away can also track it down

Any better in 0.113.2 ?

For me I have 2 systems running, one main (Pi4 supervised) and a Proxmox HAOS install (with nothing else setup).

The main one seems to top out

image

The proxmox, just keeps climbing - part of the reason I have not migrated.

Which custom integrations do you have installed?

Samba on the Proxmox one.

How are you measuring ram usage?

Is it crashing?

Just on the Proxmox UI ATM. No it’s stable, but if the underlying install is doing this, I’m concerned moving everything across will be unpleasant. I have a fair bit running.

I haven’t use proxmox in a while, but I think it doesn’t subtract buffers/cache from ram usage. FKA https://www.linuxatemyram.com/

2 Likes

I had a feeling it might, but none of the other VM/Containers exhibit the same behaviour. I was going to spin up an Ubuntu VM and do a supervised install and see what happened.

Thanks for the link. On the proxmox system;

image

So seems fine and I learnt something :slight_smile:

Thanks @bdraco for your informationen. I tried a lot to figure out whats happend in my system. At the Moment I reduced the growing rate of the memory succesfully. It was the modul “Speedtest”. In the past i had to restart the system < 24 h to work normaly. Now as we can see in the picture the memory is growing per day by around 6%. So a restart every 1,5 weeks are enought.

This is good but totally new for me. Somehow I can’t understand why it keeps now growing so slowly. This just as feedback from me.

chrome_2020-08-07_08-57-00