Excerpt from: http://www.cnblogs.com/itfriend/archive/2011/12/14/2287160.html
On-line solution: Use PS to view the memory of each process, about 4G, most of the memory is occupied by page cache. The strategy of the Linux kernel is to maximize the use of memory Cache file system data, improve the IO speed, although the mechanism is that the process requires more memory, the page Cache will be automatically freed, but does not rule out the release of memory due to fragmentation does not meet the memory requirements of the process.
So we need a way to limit the pagecache limit.
Linux provides such a parameter, min_free_kbytes, to determine the threshold at which the system starts to reclaim memory and to control the system's free memory. The higher the value, the sooner the kernel starts to reclaim memory, and the higher the free memory.
[[email protected] root]# cat /proc/sys/vm/min_free_kbytes 163840 echo 963840 > /proc/sys/vm/min_free_kbytes |
Other optional temporary workarounds:
Close Oom-killer
Cat/proc/sys/vm/oom-kill
echo "0" >/proc/sys/vm/oom-kill
Vi/etc/sysctl.conf
Vm.oom-kill = 0
2. Empty the cache (optional)
Echo 1 >/proc/sys/vm/drop_caches
Actual analysis: Memory only left 50MB,4GB memory is mostly occupied by the cache and buffer, resulting in system downtime, the current
Set the threshold value of the Min_free_kbytes
#echo 400000 >/proc/sys/vm/min_free_kbytes
But in fact, it doesn't solve the problem fundamentally.
The situation is as follows:
1) The memory gradually reduced to 50MB time, began to release, then reached 400MB, gradually use, finally back to 50MB, in turn, loop, in fact, is very dangerous, resulting in downtime, this setting is not real-time, but a threshold detection.
2) There is a print of out of memory and there is a problem with the system log.
Conclusion: The set threshold is not effective in real time, but a dynamic change process.
High Linux memory usage, triggering system downtime