OOM killer っていうか、overcommitの挙動
Linux Out-of-memory KillerにてOOM Killer の挙動が直っていない件に触れられておられたが、流石に直っていなかったっけ?と思い少し調査。
OOM Killerが動きだすのはメモリが枯渇した状況で新たにmalloc(3)つまりsbrk(2)を実行しようとしたときに生じる問題で、結局overcommitするかどうかという問題。んで、malloc(3)のmanにはovercommitの挙動の変え方が載ってある。この設定におけるデフォルトは0なので結論としては、「直ってない」。
ちなみにlinux-2.6.16のDocumentには
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 slighly more memory in this mode. This is the default.
とある。これを
2 - Don't overcommit. The total address space commit for the system is not permitted to exceed swap + a configurable percentage (default is 50) of physical RAM. Depending on the percentage 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.
に変えればOOMが動くことなくmalloc(3)に失敗するという挙動になる(はず)。