Home Assistant - High Memory Usage

Two potential options are to write some code to use objgraph to dump every object in memory every 30 seconds and see where the growth is, or remove integrations one by one until the issue goes away.

well, yeah, was afraid it would be the response :frowning: I have like 30 integrations (and of course some integration, like mqtt, are part of the core of my automation) and I need at least 12 hours to figure out if there is a memory leak.

Anyway, thanks for the response, Iā€™m gonna start with the less important one !

Reducing add-ons helped me.

Hi Brian
Did you notice a difference in behaviour after shifting to a supervised VM?

Iā€™ve been struggling with high memory usage for some months now. Iā€™m running supervised HA on RPi3b+ running Raspbian. I really canā€™t track down the root cause for increased memory usage but it started this summer. Everything worked fine for months before thatā€¦
Iā€™ve tried numerous of things to resolve this issue but nothing seemed to help until this. I increased cache size to twice the size of the RAM available on RPi3b+. After this RAM and cache usage has been steady. I havenā€™t seen the constant increase in cache and RAM usage that used to be the case before increasing the cache size. I know this might be killing my SDcard but itā€™s better than daily forced reboots. Maybe I need to migrate my setup to SSD boot.

I would recommend SSD boot setup, itā€™s pretty easy to do nowadays and the speed difference is noticeable.

Hi, I have noticed the memory consumption related to nodeRed. The more automation, especially the subprocesses in subproces, the faster the RAM clogs up.
Try to restart Node Red, if you memory the consumption will be close to 100%
For me, the memory consumption - 6Gb takes about 5 days

1 Like

Is it possible to do an automatic restart in proxmox for an hour, e.g. 02:00?

Iā€™ve created a container and installed Node-Red directly on that. Moved all flows off HA add-in that do not interact with HA directly on to the LXC.

Iā€™ve done the same for Mosquitto (MQTT) and it runs in its own LXC.

The separate LXCs make a much better job of memory management IME.

is there an instruction on how to install it on proxmox?

ok, it worked, hereā€™s a link describing how to do it

1 Like

Iā€™m finding memory usage creeps up quickly if I have a browser open on the Lovelace Dashboard. If I keep them closed memory doesnā€™t jump as quickly.

I switched from microsd to ssd boot anyway memory problems persist

1 Like

I solve this problem by calling

sysctl -w vm.drop_caches=1

in HassOS.

thanks to this article : https://codefresh.io/docker-tutorial/docker-memory-usage/

I just moved from RasPi3b to HA Blue (Odroid N2+) with 4 GB RAM after having had to restart HA every 2-3 (losing 100-200 MB memory per day). This started around Christmas, never had issues in the 9 months before that.

On the new setup I also see continuously dropping memory with steep downs when I have Lovelace open or working on the frontend (which also gets CPU and Memory of the browser on my client fired up).

So there seem to be issues related to the Frontend if thatā€™s of any help. I will see if Iā€˜ll spend hours tracking down the source of the memory leak now that Iā€˜ve thrown some money at the problemā€¦

Solved by increasing the swapfile size on RPi 3B by adding

init_commands:
  - if [ ! -f /backup/_swap.swap ]; then fallocate -l 2G /backup/_swap.swap && mkswap /backup/_swap.swap && chmod 0600 /backup/_swap.swap && swapon /backup/_swap.swap ; elif [[ ! $(dmesg|grep _swap.swap) = *swap\ on* ]]; then swapon /backup/_swap.swap; fi

in the config of SSH & Web Terminal add-on. Take a look at this github issue: https://github.com/home-assistant/operating-system/issues/968 or here in the community How to increase the swap file size on Home Assistant OS by JZhass

Iā€™m running the latest version of HA on Proxmox (running on an i7 16G). Iā€™ve just noticed on the Proxmox console a memory usage of 90% but in Home Assistant the sensor indicates a usage of less than 20%. Should I be worried ? And besides adding more memory (currently 8G), what are my options ?

Proxmox console will show you mostly always 90%. This is because it doesnā€™t know if the usage is for caching or not.
The best to do is go to the home assistant console and run first login to go to OS and then use free to know how much memory is available. If the available memory remains ā€œconstantā€ then donā€™t worry.

We had a memory increase problem back in October 2020, related to a Brother Printer integration. Iā€™ve removed that integration from my set-up, and my memory increase has ceased to be a problem. Itā€™s gone back to normal usage of around 980Mb.

1 Like

I had this issue a week or so ago and I came across your post. After removing the Brother Printer and IPP integrations, the problem is gone.

1 Like