0

I have one router which has embedded-linux with kernel version 2.4.22 running on it. I know its very old version but i have to deal with it. Please take a look at the free command output when i run it on my box

[8300002902-3] Debug> free

              total         used         free       shared      buffers
Mem:       128104       123928         4176            0         2164
Swap:            0            0            0
Total:       128104       123928         4176    

Now my problem is that whenever it execute some commands and redirects its output to some file using the > operator the buffer size is incresed by 4KB and even if i remove the same file using tm -rf the buffer again increase by 4 KB. due to this when my buffer size reaches at near 5.3MB of size the OOM problem occurs as u can see that i have only 128MB ram space available. I think the kernel is not reclaiming the buffer space. Please tell me what can be done to get rid of this problem. I have tried many things that are present over the internet like by setting the drop_caches value in the /proc/sys/vm this comamnd is not avalaible at my kernel version.Please suggest Thanks in advance.

  • `total = used + free`, that means buffers is already included. Can you add RAM or swap? – ott-- May 14 '13 at 15:21
  • Yes buffer is already included as i am usinf an embedded linux. I cant add any swap area or RAM in it. – Ankit Billaiya May 15 '13 at 04:53
  • How many programs are there running so that all of 128 MB is used? Can you show a `ps waxl`? Is it possible that you restart programs when their data size reaches a certain limit? – ott-- May 15 '13 at 17:59
  • no its not possible for me to restart the program as the router are connected in very complex & security sensitive area its not an feasible then to do so..there are many processes that i am running including most of the L2 and L3 layer protocol. – Ankit Billaiya May 16 '13 at 04:52
  • do you know what is "the program" doing? removing files is different from closing the files. You can keep files opened even after you removed them. Also, buffer is different from cache. Check how many open files you have with 'lsof'. – imel96 May 16 '13 at 06:36
  • @imel96 as i am using an embedded linux & my kernel version is also very old 2.4.22 lsof is not supported on my router. i understand the differnece b/n buffer and cache and removing or redirecting is the main problem that i have.. the problem is i am not able to reclaim that 4kb of buffer size that is increased via some operation like rm or > operator. thanks – Ankit Billaiya May 16 '13 at 13:41
  • 2.4.22 is still pretty good. you could try compile your own lsof to see what's going on. Removing files shouldn't increase or decrease number of open files. There's no way you can force the kernel to free buffers. see if this page can help http://www.linux-tutorial.info/modules.php?name=MContent&pageid=287 – imel96 May 16 '13 at 23:26

1 Answers1

0

I know you don't want to hear this, but 2.4.22 is really old and contained a number of I/O and memory related bugs. This is clearly not the expected behavior of the kernel and I suspect it doesn't have anything to do directly with output redirection or rm.

For example, this bug happens any time a file is opened and closed while O_DIRECT mode is enabled, and this bug leaks memory any time a process forks (which is what bash does when redirecting stdout).

These memoryleaks were small, so they weren't noticed as easily on non-embedded systems, but when you have only 128MB of RAM, every KB counts.

And there were plenty more little one-off memory leaks like this. The Linux kernel just wasn't the rock-solid workhorse in the early 2.4 days as it is today.

Unfortunately, I don't think there's much you're going to be able to do about it besides update to a kernel released sometime this millennium. :P

Isaac Freeman
  • 246
  • 1
  • 7