Raspberry Pi OS Monitoring - ebaauw/homebridge-rpi GitHub Wiki
I find Raspberry Pi OS becomes unresponsive when the swap file is fully in use.
In my experiance, this can happen even when the system still has free memory available.
Use Homebridge RPi, rpi info, top or htop to monitor the swap file usage.
You might want to increase the swap file size from the default 100MB to 2048MB:
sudo sed -i -e 's/^CONF_SWAPSIZE=100$/CONF_SWAPSIZE=2048/' /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon