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 4: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 4: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 6:36

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.