Swap File Problem filling to 100%

Am at a complete loss as to how to trouble shoot this further…Im running Home Assistant 115.3
HassOS 4.13 and Supervisor 245 on a Rpi 3B+
My 200mb swap file fills up at the rate of about 1mb every three - four minutes so as you can imagine doesn’t take long to fill to 100%.
The strange thing is my main core memory is showing about 630mb used and 290mb free so not sure why the swap is being used so much…
I have in testing disabled most addons which doesn’t seem to do too much…but I don’t know how to put my finger on the exact problem. I’m not sure how long I’ve had the problem for as I have only just enabled the sensor to view the swap file values…

Please help me clever people…!!

I have a 4GB Pi4 so I disabled the swap file with

sudo swapoff -a

Not sure if you have access to the Pi to run this command but if you are running off an SD card it may be worth doing it. It’s easy to SSD boot off that Pi as it’s enabled by default. With an SSD you could also increase the swap file if the Pi starts slowing down or freezing.

Unfortunately because the way they lock HomeAssistant up with the standard version that command is not allowed…my Swap file is now 100% full

Is there any way to increase the swap file size easily…

I guessed that may be the case.

My Pi4 with 4GB of ram will use the swap file if enabled even though there is plenty of RAM available so go figure. If your Pi is still stable then there shouldn’t be an issue, but, if you are running this off an SD card then you are very likely to get issues with card corruption at some point. Running off SSD would be much more preferable and stable in the long run.

Have you tried disabling your addons and integrations one by one to see if you can determine which one is causing the problem? Does the swap file usage clear up when you restart or only when you reboot? If only on a reboot it will probably be an addon causing your problem.

I have swap file issues when I have too many ONVIF cameras enabled at once (I’m still on an RPi 3 with an SD card).

The only way to reduce it is to reboot the OS…If I restart HA nothing really reduces maybe a few kilobytes

The swap file filling up is normal behaviour so unless there are stability problems it’s not an issue. As I have mentioned several times, if you are running off an SD card you are pretty certain to get card corruption in the future so the sooner you move over to SSD the better.

1 Like

Hi, I have the same problem as your colleague. My SWAP is full very often. My HA going on SSD. Is some way how to change SWAP memory if I have installed with Hassio image? Thanks

sudo systemctl stop docker
sudo dphys-swapfile swapoff
SWAPSIZE=256
sudo sed -i "s/CONF_SWAPSIZE=.*/CONF_SWAPSIZE=${SWAPSIZE}/" /etc/dphys-swapfile
sudo dphys-swapfile swapon
sudo systemctl start docker

@Johan_Lander This commands I will enter in SSH & WEB Terminal? Because I can´t enter to RPi via putty.

In the ssh terminal… Do you know how to enable it ?

I was having the exact same issue previously. I was using a Rpi 3 Model B, which only had 1 GB of RAM. It was constantly filling right up, and then the swap file would kick it. It would become unresponsive after only a few days. Automations such as motion detectors turning lights on and off were massively delayed (lights would come on 2 minutes after I left the room!). I asked on this forum and twitter. Didn’t get much help with it, to be honest.

I took a backup upgraded to Raspberry Pi 4 with 8GB and it’s been totally fine since then. The memory usage flats around 1220MB, which would have been too much for the RPi3 to be stable with.

I suspect you’re having the same problems I was having. Upgrading to a RPi with more memory was my only solution.

1 Like

@Johan_Lander Yes, I have enabled it. But this commands are unknown…

"sudo stop docker "

dphys-swapfile is not in use by home assistant OS. So these commands do not work

I had that problem on Supervised version (with Raspbian) on RPi4 with 2MB RAM. Standard SWAP filled up quickly, HA becomes less responsive. I enlarged SWAP and problem gone.

Now I went to the supported version and SWAP is high or full most the time again with, that I read, no possibility to enlarge.

I am not sure that supported version is much better for users.

experiencing similar issue.
Raspberry PI B.
|Friday, December 25, 2020|00:13|After installing Grafana & InFluxDB. system was unresponsive and had to p/c. Did not solve.|
|Friday, December 25, 2020|11:50|! Noticed Swap = 100%|
|Friday, December 25, 2020|18:55|removed Grafana & InFlux DB. Swap 84%. Responsiveness ok.|
My conclusion is that PI has reached its limit. Need more need bigger Hardware. Anyone disagree? Do not want to invest in more Hardware if not required.
Thanks,

1 Like

See if this post helps:

Has the possibility to switch “Protection mode” on/off been removed in the HassOS? I cannot see it on any add-on.

Is there some setting in the HassOS that can enable it?