I have a WRT160NL linksys router with 32MB RAM and with OpwnWRT installed. I have an application running which does some heavy writing to log files to a usb connected flash drive. (basically 26MB a day, which is almost as much as the router's memory).

What I have witnessed is that the router reboots itself every 24h or so. After monitoring various system parameters in the router, I noticed that the Buffers parameter in /proc/meminfo had a steady decline from 3kB to roughly 700B throughout the day, until it rebooted. Also, the SUnreclaim parameter has a steady increase from 8k to 13k during these 24h. Both these parameters return to 3k and 8k respectively after the reboot.

So I've noticed that the router reboots both when the Buffers parameter reaches that 700B threshold and SUnreclaim reaches that 13k threshold. At that point the load average starts steadilly increasing until it reaches a point where it has to reboot itself. I assume the decrease of the Buffers parameter is related to the increase of the SUnreclaim parameter.

Ok, so I've already tried to clear the cache to free up memory (sync; echo 3 > /proc/sys/vm/drop_cache), but it doesn't do any good but delay the problem for a very small period of time. I've also tried to tune some of the memory related variables in /proc/sys/vm/ but with little or no result (SUnreclaim keeps increasing no matter what I do - and I'm still trying some alternative tunings).

Thing is, when I run the router without the application, all these parameters are unchanged throughout the days, and the router doesn't reboot at all!

Also, when I turn off some of the logging (which is made trough pipes and redirects in bash script) the decline is less than the usual (it takes 4 days to reboot instead of 1).

So I assume the problem has to do with the Unreclaimable memory. Interpreting the name "Unreclaimable", I assume this memory is kept by the kernel and is never accessible again to the user level, meaning that I have less and less memory available throughout the hours in a system that already has very little memory to begin with...

There seams to be very little information on what the Unreclaimable Slab memory is, and why it happens. If you could explain this, I would be grateful.

Can anyone help me understand what the problem may be? Or how can I stop these declines/increases from happening, causing the router to reboot?

Sorry for the testament. Thanks in advance.

migrated from stackoverflow.com Aug 3 '12 at 16:38

This question came from our site for professional and enthusiast programmers.


It appears the problem was associated with a memory leak in the kernel's bluetooth driver, which made a small amount of memory unreclaimable everytime a bluetooth request was made (we made one every 4 seconds, so... ), thus making almost half of the router's memory unavailable to the user in a period of 24h. After applying a patch to the kernel and recompiling it, the problem seems to have disappeared.

So the heavy writing to logs was not the issue, as I had assumed, and the amount of Buffers diminishing was definitively due to the kernel clogging the memory and not because of the memory putting the whole log files into memory. I have not lost faith in linux memory management after all!

Edit: this problem seems to be present in the Linux OpenWrt kernel of Backfire (10.03, r24064).

Here is what solved the problem: http://www.spinics.net/lists/linux-bluetooth/msg13995.html

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.