Kernal

From 탱이의 잡동사니
Jump to navigation Jump to search

Overview

Linux/Unix/Windows 커널 옵션 설명 모음.

vm.overcommit_memory

원문은 이곳<ref>https://www.kernel.org/doc/Documentation/vm/overcommit-accounting</ref>에서 확인할 수 있다. 허용 가능한 메모리 용량을 넘어서는 초과 메모리 할당 요청에 대해 어떻게 응대 할 것인지를 지정하는 커널 옵션이다.

프로그램이 메모리를 요청한다고 해서, 할당받은 메모리 전부를 사용하는 것은 아니다. 실제로 사용하는 메모리(읽기, 쓰기)와 단지 할당을 요청하는 메모리의 크기는 서로 다를 수도 있다는 것이다. 이를 실제 메모리, 가상 메모리 등으로 나누어 구분하는데, 아무튼, overcommit_memory 커널 옵션이 이와 연관되어 있다.

얼핏 들어서도 굉장히 위험한 옵션이다. 할당 가능한 메모리 이상을 프로그램에 할당하게 되면 언젠가는, 정말로 메모리가 부족하게 되는 현상이 나타나게 된다. 이런 경우, 어떻게될까? OOM-killer(out of memory killer) 라고 하는 메커니즘이 발동하여 OS에서 임의로 프로그램을 종료시켜버린다(Linux kernal). 그런데 종료된 프로그램은 어떤 인터럽트가 발생하여 프로그램이 종료된지 모르게 된다. 따라서 사용에 많은 주의를 요한다.

다음은 설정 가능한 옵션 값 설명이다.

0 : 적당히 휴리스틱하게 처리.
    Heuristic overcommit handling. Obvious overcommits of
    address space are refused. Used for a typical system. It
    ensures a seriously wild allocation fails while allowing
    overcommit to reduce swap usage.  root is allowed to 
    allocate slightly more memory in this mode. This is the 
    default. 

1 : 항상 허용.
    Always overcommit. Appropriate for some scientific
    applications. Classic example is code using sparse arrays
    and just relying on the virtual memory consisting almost
    entirely of zero pages.

2 : vm.overcommit_memory_ratio 에 적용된 범위까지만 허용
    Don't overcommit. The total address space commit
    for the system is not permitted to exceed swap + a
    configurable amount (default is 50%) of physical RAM.
    Depending on the amount you use, in most situations
    this means a process will not be killed while accessing
    pages but will receive errors on memory allocation as
    appropriate.

    Useful for applications that want to guarantee their
    memory allocations will be available in the future
    without having to initialize every page.            
  • 참조
http://mimul.com/pebble/default/2013/05/10/1368171783727.html
https://charsyam.wordpress.com/2013/01/24/%EC%9E%85-%EA%B0%9C%EB%B0%9C-redis-vm-overcommit_memory-%EC%9D%84-%EC%95%84%EC%8B%9C%EB%82%98%EC%9A%94/
http://www.hanbit.co.kr/network/view.html?bi_id=1313

References

<references />