ubuntu resolves a situation in which the cache is gradually getting larger causing oom-killer to kill certain processes

Source: Internet
Author: User

Recently encountered a program after a long run time, the operating system due to out of memory caused the system Oom-killer the program directly killed the problem:

The error message is probably:

Out of Memory:kill process 20011 (main) score/sacrifice child

Killed process 20011 (main) total-vm:21688384kb, ANON-RSS:715844KB, file-rss:816256kb

These errors can be found in the Linux system's/var/log/syslog file

This is related to oom-killer issues, as detailed in: http://blog.csdn.net/gugemichael/article/details/24017515

Workaround 1:


Modify The/proc/sys/vm/lowmem_reserve_ratio file, that is: Echo >/proc/sys/vm/lowmem_reserve_ratio

1, malloc is the allocation of virtual address space, if not memset or bzero, then will not trigger physical allocate, does not map the physical address, so here with bzero fill

2, each application Block size comparison is fastidious, the Linux kernel is divided into Lowmemroy and highmemroy,lowmemory for memory resources, Lowmemroy has a threshold, through FREE-LM and

/proc/sys/vm/lowmem_reserve_ratio to see the current low size and threshold low size. When the value is below the threshold of the Oom killer, so the allocation of the block is the default 256M, otherwise, if each application 512M (greater than 128M), malloc may be the underlying BRK this syscall block, the kernel triggers page Cache write-Back or slab collection.



Workaround 2: (from http://orax.blog.sohu.com/144138537.html)

Adjust the parameters of 3 virtual memory:

L vm.min_free_kbytes=409600

L vm.vfs_cache_pressure=200

L vm.swappiness =40

The purpose of adjusting the min_free_kbytes is to keep the physical memory free enough to prevent sudden page breaks. The default of Swapiness is 60, and reducing swapiness will cause the system to release more physical memory as soon as possible by swapout process resources that are not in use. The default value for Vfs_cache_pressure is 100, which sets the tendency for virtual memory to reclaim directory and I-node buffering, and the larger the value, the more serious the recovery tendency. The purpose of adjusting these three parameters is to allow the operating system to recycle buffers as soon as possible, freeing up physical memory, so as to avoid sudden large-scale paging.

The SYSCTL command adjusts three parameters:

#sysctl-W vm.min_free_kbytes=409600//I changed here is the 3000000 Unit is k bytes (because my memory is 8GB), that is, the cache page should be at least 3GB, small let the system kernel release physical memory

#sysctl-W vm.vfs_cache_pressure=200

#sysctl-W vm.swappiness=40

After modifying the parameters, go to the/PROC/SYS/VM directory and check that the three parameters are correct:

#cd/PROC/SYS/VM

#cat min_free_kbytes

#cat vfs_cache_pressure

#cat swappiness

After the parameters have been modified, after a few minutes, the free physical memory on node 1th is significantly recovered. The description parameter does work. The above operation completes the current system adjustment, the permanent setting needs to modify the/etc/sysctl.conf parameter file.

Cd/etc

#cp sysctl.conf sysctl.conf.save20080304

#vi sysctl.conf

Add the following content:

#modify VM parameter

vm.min_free_kbytes=409600

vm.vfs_cache_pressure=200

Vm.swappiness =40

Workaround 3:

Directly modify the/proc/pid/oom_adj file, set it to 17, at this time Oom-killer Select Kill program, the process to protect the score value of 0, the higherthe score value, Oom-killer will select the program, kill it

Echo-17/proc/8163/oom_adj

Workaround 4: (from http://blog.csdn.net/tenfyguo/article/details/9409743)

Close Oom-killer directly

How to turn off and activate OOM killer:
# echo "0" >/proc/sys/vm/oom-kill
# echo "1″>/proc/sys/vm/oom-kill


Other great article articles

Android KSOAP2 call. NET Webservicejquery Tutorial (8)- Using the reverse Insert method for DOM tree operation Android Learning Note (34) using Alertdialog to create a simple dialog box Android learning Note (33) Gallery View (Gallery) features and usage Android navidgation drawer How to change the list selection in the navigation drawer ...


More about Android development articles


ubuntu resolves a situation in which the cache is gradually getting larger causing oom-killer to kill certain processes

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.