# Linux Kernel Module Cheat

###### 27.2.1.2.1. Linux out-of-memory killer

We can observe the OOM in LKMC 1e969e832f66cb5a72d12d57c53fb09e9721d589 which defaults to 256MiB of memory with:

    echo 1 > /proc/sys/vm/overcommit_memory
    ./linux/mmap_anonymous_touch.out 0x40000000 0x8000000

This first allows memory overcommit so to that the program can mmap 1GiB, 4x more than total RAM without failing as mentioned at malloc maximum size.

It then walks over every page and writes a value in it to ensure that it is used.

A Fork bomb is another example that can trigger the OOM killer.

Algorithm used by the OOM: https://unix.stackexchange.com/questions/153585/how-does-the-oom-killer-decide-which-process-to-kill-first