Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am running Ubuntu 10.04 with the below kernel version

Linux ip-10-0-1-119 2.6.32-343-ec2 #45-Ubuntu SMP Tue Feb 14 18:18:17 UTC 2012 x86_64 GNU/Linux

The memory status shows that the cache is using the maximum share of the RAM.

ubuntu@ip-10-0-1-12:~$ free -m
             total       used       free     shared    buffers     cached
Mem:          7702       7657         44          0         24       6137
-/+ buffers/cache:       1494       6207
Swap:            0          0          0

I understand that the OS manages it automatically and keeps the maximum share of RAM in the cache to minimize the cost of I/O.

The problem is during heavy load when our application requires memory and if the same amount is not available in the physical RAM the OOM killer terminates the application.

How can I tune my kernel so that if there is any memory request from my application the kernel should free some of the cache memory to make room for my application instead the OOM killer terminating it ?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

Normally, linux will clear cache for you application. What you can do is exclude your application from OOM killer. OOM killer will not terminate your application then.

echo -17 > /proc/PID/oom_adj

PID should be the PID of your program.

share|improve this answer
    
Cool trick! After all these years I did not know this. The obscure syntax might have something to do with it, but sure as hell I copied the information you provided. –  Janne Pikkarainen Mar 15 '12 at 13:33
    
@Lucas Kauffman Thanks for your reply. Can you please tell me why was Kernel not releasing memory from the cache at the first? –  Supratik Mar 16 '12 at 6:19
    
Normally it should, I suggest you install something (if you can) like munin, it logs everything and makes graphs. You should be able to find out what is happening. It might be a bug in your system or it might be your application actually blowing up your memory. –  Lucas Kauffman Mar 16 '12 at 6:27
    
@LucasKauffman does it have to do something with not having any swap? –  Sabya Mar 19 '12 at 9:23
    
Normally it shouldn't, but I always strongly advice against not having swap. –  Lucas Kauffman Mar 19 '12 at 9:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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