OpenWrt Forum Archive

Topic: How to get more free RAM?

The content of this topic has been archived on 13 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,
I compiled JFFS2 image for my DSL-362T. This modem has 8MB RAM but most of them is occupied:

Memory: 4596k/8192k available (1875k kernel code, 3596k reserved, 395k data, 120k init, 0k highmem)

After boot modem has only 620KB of free RAM:

# free
              total         used         free       shared      buffers
  Mem:         4716         4000          620            0            0
 Swap:            0            0            0
Total:         4716         4000          620

When I run simple script like

#!bin/sh
ls -lR / > /tmp/ls.txt
cat /tmp/ls.txt

...system consumes free memory and after that kill any suitable process to free memory:

Out of memory: kill process 340 (ash) score 111 or a child
Killed process 347 (cat)
watchdog invoked oom-killer: gfp_mask=0x1201d2, order=0, oomkilladj=0
Call Trace:
[<94107e64>] dump_stack+0x8/0x34
[<941566c8>] oom_kill_process+0x64/0x1cc
[<94156b90>] out_of_memory+0x1bc/0x21c
[<94159748>] __alloc_pages+0x284/0x350
[<9415c954>] __do_page_cache_readahead+0xe4/0x2b8
[<9415d0f8>] do_page_cache_readahead+0x70/0xa8
[<94155388>] filemap_fault+0x184/0x448
[<94165334>] __do_fault+0x7c/0x5ac
[<941678e8>] handle_mm_fault+0x3ac/0x7f4
[<9410bdf0>] do_page_fault+0x100/0x340
[<941015c0>] ret_from_exception+0x0/0x24

I would like to run at least simple scripts on such HW so I need more free RAM. I have tweaked kernel and busybox settings but with little success. Are there any settings I can modify to reduce for example reserved memory?

(Last edited by petrs on 24 Jun 2008, 13:20)

Try not using /tmp.  It's a tmpfs RAM drive that can grow up to 4MB (50% of the RAM size by default).

Hope this helps,
Charlie

I tried this but free RAM seems not to be affected by existence of /tmp. I simply commented out mount of /tmp in /etc/preinit but free RAM is still the same. Kernel probably allocates some amount of RAM for tmpfs by default. When /tmp partition size is ommited ds -h shows that /tmp size is approx. 2.4MB

(Last edited by petrs on 25 Jun 2008, 14:08)

The discussion might have continued from here.