Vm.overcommit_memory=2 is always the right setting for servers

Stop the phantom memory: admins cheer, Redis side‑eyes

TLDR: A popular post urges servers to use a stricter memory setting so the system stops promising space it doesn’t have and killing apps later. Commenters cheer the fail‑fast approach, while others warn big apps and forks may need swap or exceptions—reliability vs convenience takes center stage.

The blog bombshell says: set Linux’s memory mode to “2” and stop letting the system promise RAM it doesn’t have. Translation for non‑nerds: your server keeps saying “Sure, I’ve got room!” and then later silently nukes apps when it runs out. The community reaction? Ops folks are throwing confetti, devs are clutching pearls, and Redis gets dragged for “warning” people to turn the fake‑promise mode back on. renehsz comes in hot: overcommit is “fundamentally incompatible” with reliability, because you only find out you’re out of memory when the silent assassin strikes. LordGrey tries to calm the room with a concise explainer of what “2” actually does, like a teacher waving a whiteboard. Then wmf chimes in with a reality check: forking big processes needs either overcommit or a mountain of swap—hinting this is why Redis gets cranky. jleyank drops vintage vibes from the ’90s, calling the delayed crashes “Heisenbugs” and joking that nobody’s seen malloc (the memory vending machine) say “no” in ages. Animats adds nuance: even “2” can still let you thrash; it’s not a zero‑tolerance mode, just stricter. Meme of the day: “SIGKILL is the surprise party nobody asked for.” The drama is real, but the message is simple: fail fast, debug easy.

Key Points

  • The article argues Linux servers should set vm.overcommit_memory=2 to disable overcommit.
  • With overcommit enabled, the kernel returns virtual memory mappings without guaranteeing backing memory, deferring commitment to first access.
  • Disabling overcommit restores fail-fast allocation, ensuring success implies available backing memory or immediate failure.
  • Overcommit complicates debugging by causing asynchronous failures (OOM kills with SIGKILL) rather than errors at allocation sites.
  • Redis warns to enable overcommit when it runs with overcommit disabled, illustrating differing practices in software ecosystems.

Hottest takes

“This is fundamentally incompatible with the goal of writing robust and stable software which should handle out-of-memory situations gracefully.” — renehsz
“This doesn’t address the fact that forking large processes requires either overcommit or a lot of swap.” — wmf
“Has malloc ever returned zero since then?” — jleyank
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.