Openwrt 24 out of memory (8/32 device)

openwrt 23 working just fine. But installing openwrt 24 causing out of memory issues on my 8/32 device.

[   50.992134] Stack : 00000000 806d4f90 00000000 00000840 00000000 00000000 00000000 00000000
[   51.000813]         00000000 00000000 00000000 00000000 00000000 00000001 80c59ba0 128fbdfb
[   51.009486]         80c59c38 00000000 00000000 80c59ae8 00000038 80680ac4 00000000 ffffffea
[   51.018159]         000000a0 80c59af4 000000a0 80769690 8069b854 80c59b80 00000000 00000800
[   51.026833]         00000000 00000840 00000001 00000000 00000018 803b5280 00000000 80920000
[   51.035506]         ...
[   51.038042] Call Trace:
[   51.038225] [<80680ac4>] 0x80680ac4
[   51.044453] [<803b5280>] 0x803b5280
[   51.048210] [<80066218>] 0x80066218
[   51.051824] [<80066220>] 0x80066220
[   51.055434] [<806574d8>] 0x806574d8
[   51.059047] [<801d6f40>] 0x801d6f40
[   51.062859] [<801d77d8>] 0x801d77d8
[   51.066520] [<801e98a8>] 0x801e98a8
[   51.070179] [<801903fc>] 0x801903fc
[   51.073785] [<8029db5c>] 0x8029db5c
[   51.077396] [<801ac45c>] 0x801ac45c
[   51.081005] [<801ab73c>] 0x801ab73c
[   51.084616] [<8029db5c>] 0x8029db5c
[   51.088329] [<802a4458>] 0x802a4458
[   51.091987] [<8029ad74>] 0x8029ad74
[   51.095593] [<80197c30>] 0x80197c30
[   51.099353] [<8029ad28>] 0x8029ad28
[   51.103007] [<8029d7e4>] 0x8029d7e4
[   51.106614] [<8029db5c>] 0x8029db5c
[   51.110226] [<801ac728>] 0x801ac728
[   51.113985] [<8029db5c>] 0x8029db5c
[   51.117600] [<8029d7fc>] 0x8029d7fc
[   51.121210] [<8029db5c>] 0x8029db5c
[   51.124821] [<80204f60>] 0x80204f60
[   51.128680] [<803e7d64>] 0x803e7d64
[   51.132442] [<8029db5c>] 0x8029db5c
[   51.136048] [<803e7e64>] 0x803e7e64
[   51.139807] [<80243ff8>] 0x80243ff8
[   51.143461] [<80244744>] 0x80244744
[   51.147069] [<801a4468>] 0x801a4468
[   51.150828] [<80203da4>] 0x80203da4
[   51.154533] [<80244830>] 0x80244830
[   51.158293] [<8022e110>] 0x8022e110
[   51.162055] [<802156d4>] 0x802156d4
[   51.165763] [<8022e80c>] 0x8022e80c
[   51.169421] [<801fd824>] 0x801fd824
[   51.173136] [<8006d440>] 0x8006d440
[   51.176907] 
[   51.178951] Mem-Info:
[   51.181338] active_anon:978 inactive_anon:47 isolated_anon:0
[   51.181338]  active_file:1169 inactive_file:635 isolated_file:0
[   51.181338]  unevictable:0 dirty:0 writeback:0
[   51.181338]  slab_reclaimable:449 slab_unreclaimable:1306
[   51.181338]  mapped:660 shmem:68 pagetables:130
[   51.181338]  sec_pagetables:0 bounce:0
[   51.181338]  kernel_misc_reclaimable:0
[   51.181338]  free:83 free_pcp:0 free_cma:0
[   51.220092] Node 0 active_anon:3912kB inactive_anon:188kB active_file:4676kB inactive_file:2540kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:2640kB dirty:0kB writeback:0kB shmem:272kB writeback_tmp:0kB kernel_stack:504kB pagetables:520kB sec_pagetables:0kB all_unreclaimable? no
[   51.247147] Normal free:332kB boost:0kB min:100kB low:124kB high:148kB reserved_highatomic:0KB active_anon:3912kB inactive_anon:188kB active_file:4676kB inactive_file:2540kB unevictable:0kB writepending:0kB present:32768kB managed:24404kB mlocked:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[   51.274662] lowmem_reserve[]: 0 0
[   51.278109] Normal: 11*4kB (U) 10*8kB (U) 7*16kB (U) 3*32kB (U) 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB 0*8192kB = 332kB
[   51.291091] 1872 total pagecache pages
[   51.295043] 0 pages in swap cache
[   51.298475] Free swap  = 4092kB
[   51.301717] Total swap = 4092kB
[   51.304994] 8192 pages RAM
[   51.307792] 0 pages HighMem/MovableOnly
[   51.311752] 2091 pages reserved
[   51.315017] jffs2: warning: (2092) jffs2_sum_init: Can't allocate buffer for writing out summary information!
[   51.417449] Write-error on swap-device (254:0:2160)
[   51.422778] Write-error on swap-device (254:0:2168)
[   52.415588] Write-error on swap-device (254:0:2256)
[   59.166829] Write-error on swap-device (254:0:3320)
[   59.173712] Write-error on swap-device (254:0:3368)
[   59.179415] Write-error on swap-device (254:0:3400)
[   59.188328] Write-error on swap-device (254:0:3408)
[   59.194658] Write-error on swap-device (254:0:3424)
[   59.201435] Write-error on swap-device (254:0:3504)
[   59.206848] Write-error on swap-device (254:0:3512)
[   59.810974] eth0: out of memory
[   59.816611] Write-error on swap-device (254:0:4664)
[   59.822240] Write-error on swap-device (254:0:4696)
[   59.834518] Write-error on swap-device (254:0:4840)
```

No wonder.
32 MB RAM is not supported any more.

And the newer warning about limitations with 64 MB

The minimum RAM requirement was increased to 64 MB already with 21.02.0, so no wonder that 24.10.x has difficulties...

Due to new features being introduced and the general size increase of the Linux kernel, devices now need at least 8 MB of flash and 64 MB of RAM to run a default build of OpenWrt.

2 Likes

Depending upon which features you really need, you MIGHT be able to build a 24.10 customized image from src, fitting into 8/32. There are quite a lot of tweaks possible to reduce size of image. Especially makes sense, in case you have multiple devices of same type. I think, the real problem are the 32MB RAM only, because some programs have a higher initial mem requirement during startup. To introduce optimized sequential startup then.

Feel free to post output of

ubus call system board

ps

2 Likes

This means your USB swap device called it a day. Probably where that extra megabyte v24 is needing got written in a bad sector that you did not reach with v23.

Hiding entire dmesg makes it impossible to help you in any way.

there is dd-wrt is that supports your device without swapping still in 2025.

2 Likes

OpenWrt allows to run a modern OS on vintage devices. But at some point, minimum requirements for OS reach the device specs. Some tweaks (@reinerotto) may allow to continue upgrading. Finally one must accept that the device will not be able to be upgraded anymore.
These devices can still be recycled as AP or pure switch for example, by getting rid of unnecessary functions.

3 Likes

I’m using smallest possible build, but still have dmeg errors. Device keep working regardless of errors. Here is my config:

{
	"kernel": "6.6.104",
	"hostname": "OpenWrt",
	"system": "Atheros AR9341 rev 3",
	"model": "TP-Link TL-WR842N/ND v2",
	"board_name": "tplink,tl-wr842n-v2",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "24.10.3",
		"revision": "r28872-daca7c049b",
		"target": "ath79/generic",
		"description": "OpenWrt 24.10.3 r28872-daca7c049b",
		"builddate": "1758316778"
	}
}

This device has no USB swap. This is error about zram-swap.

So it had no ram to allocate a page for compressed data. oops, no way out, too much ram consumed….

Try this - namely not increasing defrag buffers part https://github.com/openwrt/openwrt/pull/19992/files

Compaction sysctl-s (/etc/sysctl.conf)

vm.swappiness=1

vm.overcommit_memory=1

But default processes do not allocate huge unused RAM, it will have just some kilobytes physical mem usage trimmed, maybe that is all you need.

1 Like

Your linked config on gitlab is not for AR9341CONFIG_TARGET_ramips_mt7621_DEVICE_hilink_hlk-7621a-evb=y . Inlcudes some good optimization, though :slight_smile:

You need tcpdump, rsync ?

And, at first glance, this should be able to be reduced, too:

CONFIG_BUSYBOX_CONFIG_LSUSB=y
CONFIG_PACKAGE_kmod-usb-core=y
CONFIG_PACKAGE_kmod-usb2=y
CONFIG_PACKAGE_kmod-usb2-pci=y
CONFIG_PACKAGE_kmod-usb-uhci=y
CONFIG_PACKAGE_kmod-usb-ohci=y
CONFIG_PACKAGE_kmod-usb-ehci=y
CONFIG_PACKAGE_kmod-phy-ath79-usb=y


I do have two devices, HLK device has a lot of RAM but it crashing sometimes due to know “timeout” issue. It have been few years with no patch. Can’t use the device.

Here is a correct link to TLWR842N

You need IPv6 or

CONFIG_PACKAGE_tcpdump=y
CONFIG_PACKAGE_rsync=y

You might post complete .config.

To save some (flash) bytes:

CONFIG_TARGET_SQUASHFS_BLOCK_SIZE = 256 (or even 1024)

If you are using fw4, just drop it and use nft cmds directly. Or no firewall at all.

The RAM chip can be replaced with a 64 MB one. This used to be a somewhat popular mod, but now 64 isn't really enough either.

I can’t find cheap one. Aliexpress selling those for full router price.

I tested all recent versions of openwrt and find out that v21 works the best! Even wpad-mini works without OOM errors at full speed. Which is not works for v23 and v22. Sad to see openwrt goes memory hungry way.

To be clear.... this is not the fault of OpenWrt, per-se, but rather the growth in the Linux kernel.

Take a moment to consider how incredible it is that you're able to run the latest OpenWrt -- a full featured routing OS -- in just 64MB (that's megabytes) of RAM and 8MB of flash (minimum requirements). Compare that against any modern desktop OS and you're talking in the order of 4GB RAM and 64GB (that's gigabytes) of storage.

As the Linux kernel advances, it also grows in terms of resources required (RAM and storage). OpenWrt gets its kernel from the upstream in order to stay current with features, but more importantly security and functional compatibility.

5 Likes

No doubt about that. Is it just kernel? Maybe we can tweak compile flags and remove some security layers to reduce memory consumption? It would be even cooler to run recent openwrt on old hardware with basic features like ssh, routing, wpad-mini (no luci)

1 Like

“ …. work best ….” Only to be confirmend after long term usage. Cause quite a few bug fixes in various drivers and packages between v21 and v24. However, CC might be “best” openwrt version for you :slight_smile:

Other things do tend to grow a bit based on the kernel -- so dependencies such as kernel modules and the like will often get bigger, too. This overall slowly causes the system's total resource requirements to grow over time. There are other threads about this, including, IIRC, some that did some rough calculations showing the effect of the kernel vs other components.

I'm not a developer, so I cannot comment with any technical advice here. But would you really want to reduce the security posture of your router? This is the thing that keeps your network and devices safe from direct exposure to the internet. That's like the "3 little pigs" building a brick house and not installing windows or doors (just holes where they'd go).

1 Like

Tweaking the kernel, drivers and core packages to fit into 32 MiB is a massive waste of time, and time is money. A 128/256 MiB OpenWrt-compatible device can be found within the $20-$40 price range, and I refuse to believe you can't make at least 4x that value in the time you would be spending hacking, compiling and testing.

4 Likes

This depends on. I did this tweaking several times for fleets of (identical) hotspot devices. There it makes commercial sense, and also regarding the environment, BTW. In case of single device only, you are definitely right. Although, good learning expirience, anyway :slight_smile:

1 Like