Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have problem with embedded linux boxes. Some boxes has a memory leak.

None of the processes does not hold the leaked memory.

After killing all possible processes, the leak still exists. When looking from /proc/meminfo, it seems that leaked memory is under Inactive memory:

~ # echo 1 > /proc/sys/vm/drop_caches ; cat /proc/meminfo
MemTotal:       126744 kB
MemFree:        107684 kB
Buffers:             0 kB
Cached:           1160 kB
SwapCached:          0 kB
Active:           1204 kB
Inactive:        12532 kB
SwapTotal:           0 kB
SwapFree:            0 kB

~ # ps        
    1 root      2748 S    init       
    2 root         0 SW<  [kthreadd]
    3 root         0 SW<  [ksoftirqd/0]
    4 root         0 SW<  [events/0]
    5 root         0 SW<  [khelper]
   31 root         0 SW<  [kblockd/0]
   42 root         0 SW<  [khubd]
   48 root         0 SW<  [kmmcd]
   82 root         0 SW   [pdflush]
   83 root         0 SW   [pdflush]
   84 root         0 SW<  [kswapd0]
   85 root         0 SW<  [aio/0]
  170 root         0 SW<  [rpciod/0]
  176 root         0 SW<  [mmcqd]
 1346 root      2756 S    telnetd -l /bin/login 
 1347 root      2856 S    -sh 
 3737 root      2856 R    ps 
~ #

Ram disks are not in use. Linux version is

Is there any way to find reason why the Inactive memory increases all the time? Is it possible to flush or drop Inactive memory?

share|improve this question
How do these memory leak problems manifest themselves? Do you get an error message when running a certain program? What is the program and exact error message? – RedGrittyBrick Apr 24 '12 at 9:27
We are trying to monitor memory usage, and raise alarm when memory usage increases over 40%. Several customers have noticed the alarm. And now we are investigating reason of the alarm. After 2 answers, it seems that our sw counts the used memory wrongly. – User1 Apr 24 '12 at 10:24
Your whole reasoning is wrong. The whole purpose of memory is to be used. Using most of your memory is completely normal. Modern computers use as much memory as possible to improve performance. Unused memory is completely wasted. It's not like if you use only half the memory now, you can use twice as much tomorrow. Any memory you don't use today is performance forever lost. – David Schwartz Apr 25 '12 at 1:50
Yes, I understand that. The only purpose is to detect possible memory leak before the leak causes problems. We are not going to drop caches or etc in production envinronments. – User1 Apr 25 '12 at 12:18
up vote 3 down vote accepted

Inactive memory is not a problem, certainly not a "leak"; it is memory pages which have typically been used for buffering files or executables that are not currently running, and are being held for possible re-use. If something needs the data in them (reading the same file or running the same program) then they will be reused without hitting disk again; if something else needs the pages, however, their inactive state means they will be used when needed.

Put slightly differently, think of free memory as memory which has never been allocated; inactive memory is memory which has been allocated and freed.

share|improve this answer
Inactive memory is first in line to be freed. If it had already been freed, it would be free, not inactive. (In his case, I'm guessing that most of the inactive memory is memory that he forced out of the cache by dropping the page cache.) – David Schwartz Apr 25 '12 at 1:52

There is no evidence of a leak of any kind in the data you posted. The memory is properly tracked as inactive. If you do a sync before the drop_caches, you probably won't see so much inactive memory, but you are creating it by forcing pages out of the cache. If they can't be freed (say they're dirty) they become inactive.

You can force dirty, inactive memory to be synched faster by running sync, but I can't imagine any possible reason to do this. You can't force clean, inactive memory to be freed, nor can I imagine any reason you would want to. The system can already discard it and it's already first in line for use when the free memory pool is exhausted. Why do you want it to be freer?

If you don't want the system to use the memory, take it out of the machine and sit it on your desk. Because right now, you're just making it slow the system down by forcing the system to shrink the caches and flush dirty pages more rapidly than it would want to, causing tons of needless I/O. Just leave it alone and let it do its job.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .