What killed my process and why?

后端 未结 14 962
误落风尘
误落风尘 2020-11-22 09:34

My application runs as a background process on Linux. It is currently started at the command line in a Terminal window.

Recently a user was executing the application

14条回答
  •  长情又很酷
    2020-11-22 10:03

    Let me first explain when and why OOMKiller get invoked?

    Say you have 512 RAM + 1GB Swap memory. So in theory, your CPU has access to total of 1.5GB of virtual memory.

    Now, for some time everything is running fine within 1.5GB of total memory. But all of sudden (or gradually) your system has started consuming more and more memory and it reached at a point around 95% of total memory used.

    Now say any process has requested large chunck of memory from the kernel. Kernel check for the available memory and find that there is no way it can allocate your process more memory. So it will try to free some memory calling/invoking OOMKiller (http://linux-mm.org/OOM).

    OOMKiller has its own algorithm to score the rank for every process. Typically which process uses more memory becomes the victim to be killed.

    Where can I find logs of OOMKiller?

    Typically in /var/log directory. Either /var/log/kern.log or /var/log/dmesg

    Hope this will help you.

    Some typical solutions:

    1. Increase memory (not swap)
    2. Find the memory leaks in your program and fix them
    3. Restrict memory any process can consume (for example JVM memory can be restricted using JAVA_OPTS)
    4. See the logs and google :)

提交回复
热议问题