flatiron: What is an "OOM killer"?
The OOM (Out Of Memory) killer is a part of the Linux kernel (don't know how other OSes handle this situation) that is called if the system runs completely out of memory and swap space and is unable to free any memory; it is the method of last resort.
Basically, if Linux runs out of memory, it tries to free up memory, and will first try the following things:
* If there's a clean page backed by a file (that is, the memory is a copy of the file, and neither has been altered), the kernel can just drop the memory page (it can be read from disk later if needed again).
* If there's a dirty page backed by a file (that is, the memory or file has been changed), the page can be dropped, but only if the changed data is written to disk first.
* If the page is not backed by a file, it can be saved to the swap partition or file. When a program tries to access that memory later, the CPU will trigger a page fault, and the kernel will read that page back from disk into RAM (assuming it can free up some memory, of course). This is what is commonly referred to as "virtual memory".
If the kernel can't free up memory this way, the OOM killer is then invoked. The OOM killer scores each process based off factors like how much RAM the process and its children are using, as well as how long the process has been running. The result of the OOM killer is that some process will be killed, and any unsaved data the process had will be lost. As you can see, the OOM killer is the kernel's method of last resort for freeing up memory if all else fails.
(Generally, if the OOM killer is ever called during normal operation, something has gone wrong. There might be a runaway process leaking memory (hopefully that one becomes the OOM killer's victim), or you might need to add more RAM or swap space.)
If even the OOM killer fails (this is rare, and typically involves something like a ramfs eating all phyical memory, or a kernel memory leak), then the kernel will panic. (A kernel panic is the Linux equivalent of a blue screen.)
If you want more details on how the OOM killer chooses its victim, including some source code excerpts from the Linux kernel, you can go to
https://linux-mm.org/OOM_Killer or just go to your favorite search engine.