'wpad' memory usage

Hello! I'm using openwrt on low memory device and comparing different release trying to find one which is sutable for 8/32 device. It seems like here is an issue with 'wpad' which is preventing using it no matter what version of openwrt is on board.

I tried to tweak my kernel and OOM to get most of RAM free. Results are very impressive, My router 8/32 (with total 25MB RAM) gives 12MB free. But no matter what, as soon I enable wpad router start to crash with OOM.

Here is some information.

No wpad enabled gives 12MB free.

Mem: 21212K used, 4624K free, 36K shrd, 0K buff, 7072K cached
CPU:   0% usr   0% sys   0% nic 100% idle   0% io   0% irq   0% sirq
Load average: 0.07 0.02 0.00 1/44 11287
  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
11287 11266 root     R     1384   5%   0% top
 1408     1 root     S     2112   8%   0% /sbin/netifd
    1     0 root     S     1940   8%   0% /sbin/procd
 2715     1 root     S     1788   7%   0% /usr/sbin/miniupnpd -f /var/etc/miniupnpd.conf
 1521     1 root     S     1760   7%   0% /usr/sbin/odhcpd
 2166     1 dnsmasq  S     1668   6%   0% /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg01411c -k -x /var/run/dnsmasq/dnsmasq.cfg01
  489     1 ubus     S     1484   6%   0% /sbin/ubusd
 1036     1 logd     S     1480   6%   0% /sbin/logd -S 64
 2279     1 root     S<    1376   5%   0% /usr/sbin/ntpd -n -N -S /usr/sbin/ntpd-hotplug -p 0.openwrt.pool.ntp.org -p 1.openwrt.poo
 1581     1 root     S     1376   5%   0% /usr/sbin/crond -f -c /etc/crontabs -l 5
11266 11265 root     S     1376   5%   0% -ash
 2961     1 root     S     1372   5%   0% ash -c while true; do free; sleep 1 ; done
11286  2961 root     S     1372   5%   0% sleep 1
11265  1275 root     S     1292   5%   0% /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3 -W 262144 -2 9
 1275     1 root     S     1272   5%   0% /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3 -W 262144
  525     1 root     S     1208   5%   0% /sbin/urngd
  490     1 root     S     1056   4%   0% /sbin/askfirst /usr/libexec/login.sh
  260     2 root     IW       0   0%   0% [kworker/0:4-eve]
    9     2 root     SW       0   0%   0% [ksoftirqd/0]
  280     2 root     IW<      0   0%   0% [kworker/0:1H-kb]
   58     2 root     SW       0   0%   0% [spi0]
   13     2 root     SW       0   0%   0% [kcompactd0]
    6     2 root     IW       0   0%   0% [kworker/u2:0-ev]
   23     2 root     SW       0   0%   0% [kswapd0]
  262     2 root     IW       0   0%   0% [kworker/u2:3-ev]
  247     2 root     IW<      0   0%   0% [mld]
   31     2 root     IW<      0   0%   0% [kthrotld]
  249     2 root     IW<      0   0%   0% [ipv6_addrconf]
  291     2 root     SW       0   0%   0% [irq/16-keys]
   20     2 root     IW<      0   0%   0% [kblockd]
   12     2 root     IW<      0   0%   0% [writeback]
   11     2 root     SW       0   0%   0% [oom_reaper]


root@OpenWrt:~# free
              total        used        free      shared  buff/cache   available
Mem:          25836       13260        4704          36        7872       12140
Swap:        262140         768      261372

wpad enabled and running it takes 27% or RAM ~ 7MB, still 11MB free

Mem: 20436K used, 5400K free, 24K shrd, 0K buff, 5644K cached
CPU:   0% usr   0% sys   0% nic  90% idle   0% io   0% irq   9% sirq
Load average: 1.22 0.69 0.27 1/51 2886
  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
 1230     1 root     S     3544  14%   0% /usr/sbin/hostapd -s -g /var/run/hostapd/global
 1231     1 root     S     3388  13%   0% /usr/sbin/wpa_supplicant -n -s -g /var/run/wpa_supplicant/global
 1295     1 root     S     2220   9%   0% /sbin/netifd
    1     0 root     S     1944   8%   0% /sbin/procd
 2651     1 root     S     1788   7%   0% /usr/sbin/miniupnpd -f /var/etc/miniupnpd.conf
 1408     1 root     S     1760   7%   0% /usr/sbin/odhcpd
 2261     1 dnsmasq  S     1668   6%   0% /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg01411c -k -x /var/run/dnsmasq/dnsmasq.cfg0
  491     1 ubus     S     1492   6%   0% /sbin/ubusd
  873     1 logd     S     1480   6%   0% /sbin/logd -S 64
 2886  2713 root     R     1384   5%   0% top
 2713  2712 root     S     1376   5%   0% -ash
 1998     1 root     S<    1376   5%   0% /usr/sbin/ntpd -n -N -S /usr/sbin/ntpd-hotplug -p 0.openwrt.pool.ntp.org -p 1.openwrt.po
 1468     1 root     S     1376   5%   0% /usr/sbin/crond -f -c /etc/crontabs -l 5
 2712  1112 root     S     1292   5%   0% /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3 -W 262144 -2 9
 1112     1 root     S     1272   5%   0% /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3 -W 262144
  527     1 root     S     1208   5%   0% /sbin/urngd
  492     1 root     S     1056   4%   0% /sbin/askfirst /usr/libexec/login.sh
  280     2 root     IW<      0   0%   0% [kworker/0:1H-kb]
  260     2 root     IW       0   0%   0% [kworker/0:4-eve]
    9     2 root     SW       0   0%   0% [ksoftirqd/0]
   23     2 root     SW       0   0%   0% [kswapd0]
  262     2 root     IW       0   0%   0% [kworker/u2:3-ph]
   58     2 root     SW       0   0%   0% [spi0]
  147     2 root     IW       0   0%   0% [kworker/u2:2-ph]
   13     2 root     SW       0   0%   0% [kcompactd0]
   25     2 root     IW       0   0%   0% [kworker/u2:1-ev]
  416     2 root     SWN      0   0%   0% [jffs2_gcd_mtd4]
    6     2 root     IW       0   0%   0% [kworker/u2:0-ev]
  231     2 root     IW       0   0%   0% [kworker/0:2-eve]
   22     2 root     SW       0   0%   0% [watchdogd]
   24     2 root     IW       0   0%   0% [kworker/0:1-eve]



root@OpenWrt:~# free
              total        used        free      shared  buff/cache   available
Mem:          25836       13808        5624          24        6404       11604
Swap:        262140        1280      260860

When I'm loading wifi 100% by downloading torrent, OOM start to kick in and killing hostap with 9MB free RAM and 256MB swap.

Tue Apr 22 14:07:08 2025 kern.info kernel: [  336.042713] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),global_oom,task_memcg=/,task=hostapd,pid=1230,uid=0

              total        used        free      shared  buff/cache   available
Mem:          25836       16144        4564          12        5128        9284
Swap:        262140        1024      261116

I think wpad using too much memory to begin with. And OOM should be configured not to kill processes when here is plenty of memory available. Test data provided for v23 wpad-mini