Adguard crashes all the time: out of memory

Anyone with this issue could try zram-swap to give the router "more" ram. Setup is pretty easy, log in using ssh and run these commands:

opkg update && opkg install zram-swap
uci set system.@system[0].zram_size_mb='64'
uci set system.@system[0].zram_comp_algo='lz4'
uci commit && reboot

The first command will update the package lists and install two packages (kmod-zram + zram-swap).

The next two commands set the size and compression method. For available compression methods we can check /sys/block/zram0/comp_algorithm I only have lz* and no zsdt or other methods in my Opal, but on others this could be different and make a big difference. Select zsdt if available.

# cat /sys/block/zram0/comp_algorithm 
lzo [lz4] deflate

The final command applies the settings and reboots. You can verify if it works by running htop which should show an active swap of whatever the size is you set. Recommended is using 50-60% of ram, that would be 64 for my Opal router.

What we now have is a swap that stores data compressed in ram of the router. This should help a lot when having big blocklists as they're mainly text which compresses pretty well. This might give you the extra space you needed to have a lot of lists.

Please let me know how if it helped you!

And yes you've essentially downloaded more ram, a thing some people claim is impossible!

PS: I am pretty certain compression is handled by a cpu instruction because it doesn't seem to cause any increase in cpu usage in my testing. Related to that; if you run a VPN make sure to select an encryption method the cpu supports, it will greatly improve performance by reducing cpu load.

3 Likes