Several times in the past week (and from my impression it was often not long after triggering an upgrade if that may be related), my recent install of Home Assistant has locked up due to exhausting the memory. RPi3 only has 1 GB RAM, and for some reason the HassOS image only comes with 200 MB swap by default.
Due to the poor logging with this setup I have not been able to see what’s going on when the memory is all gone. Even though I’ve resorted to keeping a separate PC always on to stream certain logs over ssh, it still eludes me. Top shows the python3 process memory utilization spontaneously and quickly grow out of control. dmesg just shows a notice when python3 memory allocation fails. home-assistant.log with default logging enabled shows nothing out of the ordinary. No other log showed any indication of problems. I will try to enable debug logging for homeassistant.core next.
Now I have also added a 4 GB file-based swap using mkswap and swapon. If this is used a lot it may cause the system to grind to a snails pace, but if it’s fleeting then it’s better than locking up. Time will tell if the same high memory utilization will result in a lock-up or just a temporary high-water mark.
At this point, with the lack of logging, HassOS seems stripped almost beyond usefulness. That Home Assistant removing its own log file each restart is also a weird design choice and makes debugging crashes or lock-ups harder than necessary.
-
Are there any established ways to troubleshoot memory exhaustion problems?
-
How can I make the swap file automatically get loaded at host OS start-up?