High Linux memory, triggering Oom-killer Problem Solving

Source: Internet
Author: User

Two Linux memory problems have occurred recently. One is that Oom-killer is triggered to cause system crashes.

1. First confirm that the system version is 32-bit

 
# Uname-alinux alarm 2.6.9-67. elsmp #1 SMP wed Nov 7 13:58:04 est 2007 i686 i686 i386

2. Let's take a look at the 32-bit Linux memory management structure.

 
# DMA: 0x00000000-0x00999999 (0-16 Mb) # lowmem: 0x01000000-0x037999999 (16-896 MB)-size: 880 MB # highmem: 0x038000000- 

The kernel uses low memory to track all memory allocations. In this case, a 16 GB memory system consumes more low memory than a 4 GB memory system. When low memory is used up, even if the system still has the remaining memory, Oom-killer is triggered. In the 2.6 kernel, the process that occupies the highest memory is killed. Therefore, sshd and other processes are killed, causing the system to log on.

3. How to view lowmem

-Bash- 3.00 # Free-LM
Total used free shared buffers cached
Mem:2026 1973 52 0 36 1303
Low: 874 823 51
High: 1151 1150 1
-/+ Buffers/cache: 633 1392
Swap:3067 142 2924

4. Therefore, we need to protect lowmem. The lower_zone_protection is introduced in the 2.6 kernel, which will make the kernel willing to protect low memory and give priority to high memory allocation when allocating memory.

 
-Bash-3.00 # Cat/proc/sys/Vm/lower_zone_protection0-bash-3.00 # echo 400>/proc/sys/Vm/lower_zone_protection

Another problem is that the 24 GB memory system has less than 50 MB of idle memory.

1. confirm that the system version is 64-bit.

 
# Uname-alinux gxgd-NMS-app 2.6.18-194. el5xen #1 SMP Tue Mar 16 22:01:26 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

2. view the memory of each process in PS, which occupies about 4 GB, and most of the memory is occupied by PAGE cache. The Linux kernel policy is to use the data in the memory cache file system to maximize Io speed. Although the page cache is automatically released when a process requires a larger memory, however, it is not ruled out that the released memory is not timely or that the memory fragments do not meet the memory requirements of the process.

Therefore, we need a method to limit the upper limit of pagecache.

Linux provides the min_free_kbytes parameter to determine the threshold value for the system to recycle memory and control the system's idle memory. The higher the value, the earlier the kernel starts to recycle memory, and the higher the idle memory.

 
[Root @ zyite-app01 root] # Cat/proc/sys/Vm/min_free_kbytes163840echo 963840>/proc/sys/Vm/min_free_kbytes

Other optional temporary solutions:

Disable Oom-killer

CAT/proc/sys/Vm/Oom-kill
Echo "0">/proc/sys/Vm/Oom-kill
VI/etc/sysctl. conf
VM. Oom-kill = 0

2. Clear cache (optional)
Echo 1>/proc/sys/Vm/drop_caches

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.