I have raspberry PI 4B 4GB RAM with openwrt 22.03.2 firmware. I have intermittently lost of wan problem. I suspect the problem is from abnormal high memory usage. The memory usage is 144MiB/3.71GiB 4% after rebooting, and then it climbs up and eats all memory, see snapshot below:
144 MB RAM usage would be a bit higher than expected, but not necessarily a problem - the continuously rising RAM usage however certainly is.
Given that there is quite a big potential of 'misconfiguration' (rogue logging, server processes filling up /tmp/ or similar issues), I would start debugging by having a look at the file sizes under /tmp/ and RAM usage of the process via (e.g.) htop, if you don't find a likely culprit rather quickly, starting over with a fresh configuration/ fresh flash and a minimal setup (just WAN/ LAN and the necessary VLAN setups, if applicable) and have a look what happens there for ~a week, before slowly enabling additional features one-by-one.
While the RPi ecosystem might not be the most pleasant one for developers, it has a strong following by OpenWrt users, so I'd be surprised if this was a generic issue for these devices.
Install htop and now I am confused with the memory usage result.
htop shows 53.4MB/3.71GB when openwrt is showing 320MiB/3.71GiB in the luci overview page(I rebooted the router an hour ago so the memory usage is 320M at this moment).
The two values don't match each other.
Now I found what is causing the high used memory. I have USB harddrive attached to Pi and shared by samba. I stored a VHD in the USB drive. Everytime I start this VM(the VM uses VHD in shared USB drive) from my laptop, the memory usage increases to the almost the maximum. However, the memory usage stays even after I shut down the vm.
I tried to restart Samba service, it won't reduce the memory usage. How to release the used memory after VM is shut down? or enabling swap space will help?