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 ?
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.
PID should be the PID of your program.