Home Assistant keeps running out of memory

Dear community:

I have used Home Assistant to replace OpenHAB and HomeBridge since the beginning of May. I’m very happy with the switch and I got much more functionalities and usability. However one thing that I keep fight for is memory consumption, initially it stays around 4-5GB but after running for a couple of days it hits higher limit (I assigned 7GB for the VM), and randomly the UI disconnects and restarts. Today when I check the console from VM I got the below error, which is beyond my IT knowledge, does anybody know it means?

In my setup I use the below add-ons (Samba has been turned off), the usage of memory looks normal to me (around 0.1%-3% each):

I have in total 162 devices, around 1000 entities, 40 helper and around 50 automation rules. I read here usually HA can run on RPI with 4GB memory, is my setup too big to run with 7GB memory?

Since the memory allocation happens dynamically and it’s hard to get more insight. Appreciate any suggestion, thank you in advance!

What OS are you running the VM on ? Your log errors points more towards the CPU usage.

Start in safe mode. That will disable all 3rd party integrations and cards. If the memory stops climbing you know it is one of them that has a memory leak.

Also check your automations and scripts for loops that never exit.

Thank you! I’m running HA as VM on Qnap NAS, the OS is QTS I believe it’s a modified version of linux.

Thank you! I have double checked and there is no infinite loops, the thing is the memory usage is already very high when it just get started (around 6GB). Is it expected with the amount of devices/entities I have? I wish I could assign more ram but my NAS only supports 16GB :frowning:

Something is eating up your memory. All my HA installs with several addons and integrations are setup on VM’s with 4GB of memory. My home runs 1,4GB and office 1,3GB and test is at 2GB

Are you seeing this RAM usage from HA itself or from the VM?

What do the addons show RAM wise?

1 Like

Do you see the same high memory usage when starting in Safe Mode as Tom suggested?

  1. How many VMs are running on the NAS?

  2. What VM software ware you using? VMware?

1 Like

Stop Studio Code Server when it’s not in use.

2 Likes

Thank you all for your replies! I have tried to disable/enable add-ons and integrations one by one, and I found it’s dreame integration brings up the memory significantly (it uses 2.5GB). All add-ons use less than 400MB.

2 Likes

Studio Code Server appears to use very little memory at first, but as you use it, it takes more, particularly if you have several tabs open. When a tab is closed, memory is not released and over time it will consume nearly all of it. It’s a feature. :grin:

1 Like

Where do you check the values for memory?
The hypervisor values can’t be used!

I check in HA settings/hardware - it reflect immediately when I turn on/off an integration. The memory in VM stays the same at near max with no change, I read somewhere it’s a feature of Linux to use as much memory as possible.

Understood will turn it off as I don’t use it very often those days. Thanks for the suggestion!

when you say the VM stays the same is that the value from your hypervisor, because that value can not be depended on.

Yes I believe what you refer to as hypervisor.

Why? EXS shows both allocated and active memory and depending on vartious task performed by HA VM I can see how active allocation changes. What might be wrong with hypervisor reporting?

Cached memory is considered free memory in HA, but it will be shown as allocated or cached memory in the hypervisor.

1 Like

no need to turn it off, just make an automation which will restart addon daily at midnight:

  - action: hassio.addon_restart
    data:
      addon: a0d7b954_vscode

That’s what i did and there’s no problems. If you find any other addon who’s eating memory add it to above automation. If i remember correctly for example Firefox addon eats memory, too. Not as agressive as VSCode, but it does.

2 Likes

Thanks how do you find the add on id?

Edit: found it it’s also the same for me, thanks a lot!

Any add-on I don’t use, I turn off. ESPHomebuilder, File Editor, MQTT Explorer, Portainer, TasmoAdmin, … Turn on when used, turn off when not in use.