Linksys MX4200 Memory Issues

I am having problems with MX4200v1. The router goes low on available memory and eventually dies. It still replies to ping and its wireguard peer's status shows active connection but nothing else seems to function.

I found a workaround -- if I enable swap on a usb drive the router functions fine (though the available memory fluctuates, going pretty low at times). Interestingly, swap does not seem to be heavily used -- I saw at most 5-7MB of swap in use. I tried enabling zram-swap instead of a physical usb -- the router crashes again.

The running services are: luci, uhttpd, wireguard, and pbr. I have wifi enabled on all 3 radios and one of them also has a guest network enabled (so no clients are connected to it at the moment).

Any suggestions on solving this problem?

this thread isn't actually about the 4200, but the (so far unsupported) 4300....

I know that the current discussion is centered on MX4300 but the thread sure has MX4200 in the subject and until some time in May it was exclusively about MX4200. If there is a better thread for MX4200, I am happy to ask there. But this seems to be the thread with participation of people who actively work on MX4200/MX4300.

1 Like

I had the same issue, was never able to solve it but you could try zram see if that helps, make the zram swap more aggressive so it's using zram all the time

Thanks for the suggestion. I tried using zram with no success. I will try it again with higher swappiness value but unless someone offers a working solution, my experiments will have to wait a couple of weeks until I have that router in my physical possession. (For now I was accessing it remotely. And since it does work with the swap on an external drive I should stop breaking the Internet for the person using the router.)

I did try to see if it's a memory leak when I ported Openwrt to mx4200 but it never was, seems to me that the bdf is taking up the ram

What's puzzling is that swap on a physical drive fixes the problem even though it is barely used. Right now only 0.25-0.5MB of swap is used, the available memory is at 5MB (without a swap this would imply that a crash is reasonably close) but based on the past experience I'm pretty sure the router will continue running smoothly.
As I said, zram swap with the same default swappiness setting didn't help (may have brought the crash sooner).

A few more observations:
A second router that serves as a dumb AP with luci-proto-relay running but dnsmasq (and a few more services) disabled runs without hiccups.

I think another pair of routers exhibits the same behavior: the dumb AP is fine while the main router dies. That pair runs mesh 802.11s but no wireguard (which means that for now my observations on that pair are not repeatable since I have no physical access to that pair either).

(As I slowly typed this on a phone, swap use increased to 1.5MB, the available memory increased to 20MB.)

One often overlook aspect of swap is, that the kernel can use it to 'defragment' the RAM, allowing large ('bad') contiguous memory allocations to succeed. I wouldn't exactly call this a 'solution' though.

agreed its not a solution, more so a temporary work around

Another interesting observation is -- I reinstalled firmware, removing all extra packages except for luci, luci-app-uhttpd, wireguard and pbr. After running it for 24 hours with wireguard interface and pbr disabled I had no crashes. Moreover, I did not see available memory wildly fluctuating and going close to zero. Maybe 24 hours is not long enough...

I also enabled wireguard and pbr a couple of hours ago and no memory fluctuations so far.
So maybe the issue is that installed too many packages for this router (even though most of the additional services were disabled).

Yeah it's a ath11 fw issue, the more devices connected the more memory is available same issue is happening on Xiaomi AX3600