---
title: "Why strict memory overcommit matters for Postgres"
description: "Under Linux's default overcommit policy, an OOM-killed Postgres backend forces the postmaster to terminate all backends and run crash recovery."
url: "https://swe.quest/articles/why-strict-memory-overcommit-matters-for-postgres-b9d0f67bf7c921e4"
canonical: "https://clickhouse.com/blog/strict-memory-overcommit-for-postgres"
source: "ClickHouse"
published: "2026-07-28"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["postgres","linux","memory-management","resilience"]
---

# Why strict memory overcommit matters for Postgres

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2026-07-28, 7 min read, Case study. Original: [https://clickhouse.com/blog/strict-memory-overcommit-for-postgres](https://clickhouse.com/blog/strict-memory-overcommit-for-postgres)

## Summary

Under Linux's default overcommit policy, an OOM-killed Postgres backend forces the postmaster to terminate all backends and run crash recovery. Strict overcommit (vm.overcommit\_memory=2) instead makes malloc return ENOMEM, so only the offending query fails. ClickHouse Managed Postgres sets an explicit vm.overcommit\_kbytes of 80% of non-huge-page memory plus 2GB, roughly 60% of RAM plus 2GB, which leaves memory free to handle the error. On an m7i.2xlarge, the default policy dropped all 20 sessions with 30.2s of downtime, strict overcommit caused one query error and no dropped connections, and pgbench showed no measurable throughput cost.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Linux](https://swe.quest/tags/linux.md) (Infrastructure)
- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)
- [Resilience](https://swe.quest/tags/resilience.md) (Distributed systems)

## Prerequisites

- Linux virtual memory basics ([easy posts on Linux](https://swe.quest/tags/linux.md?difficulty=easy))
- Postgres process architecture ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- WAL and crash recovery

## Keywords

vm.overcommit\_memory, OOM killer, ClickHouse Managed Postgres, huge pages, pgbench, shared\_buffers

## Related posts

- [Can your Postgres survive a bad query?](https://swe.quest/articles/can-your-postgres-survive-a-bad-query-744ea9a22b65710c.md): ClickHouse · 2026-09-28 · Hard · 13 min read · PostgreSQL, Memory management, Resilience, Query engines, Linux
  Postgres's \`work\_mem\` limits memory per plan node per process, not per query, so parallel workers and \`hash\_mem\_multiplier\` can push a simple aggregation past 8x \`work\_mem\`.
- [How we configure huge pages in ClickHouse Managed Postgres](https://swe.quest/articles/how-we-configure-huge-pages-in-clickhouse-managed-postgres-6544ec044914bebf.md): ClickHouse · 2026-07-14 · Medium · 5 min read · PostgreSQL, Linux, Performance engineering, Memory management, Configuration management
  ClickHouse Managed Postgres runs every server's shared\_buffers on 2MB huge pages, which avoids per-backend page-table bloat and improves TLB reach.
- [What else runs on your Postgres server, and how do we stop it from taking the database down?](https://swe.quest/articles/what-else-runs-on-your-postgres-server-and-how-do-we-stop-it-from-taking-the-79e9559393b71ab0.md): ClickHouse · 2026-08-21 · Medium · 4 min read · PostgreSQL, Linux, Memory management, Resilience, Multi-tenancy
  Supporting processes on a managed Postgres VM (PgBouncer, WAL-G, Prometheus, exporters, log collector, watchdogs) share memory, CPU and disk with the database, so a leak or CPU burst in any of them can take it down.
- [Incident Report: May 4th, 2024](https://swe.quest/articles/incident-report-may-4th-2024-b8a15a36661e2277.md): Railway · 2024-05-08 · Medium · 6 min read · Incidents & postmortems, Multi-tenancy, Capacity planning, Scheduling, Linux
  A single self-service customer workload deployed multiple memory-hungry replicas into Railway's smallest region, Asia-Southeast, and exhausted its memory.
- [What is WAL backpressure, and why does ClickHouse Managed Postgres need it?](https://swe.quest/articles/what-is-wal-backpressure-and-why-does-clickhouse-managed-postgres-need-it-a02421af1a627e86.md): ClickHouse · 2026-08-05 · Hard · 4 min read · PostgreSQL, Resilience, Linux, Storage systems
  ClickHouse Managed Postgres prevents WAL-full PANICs, which happen when writes outpace archiving to object storage, by throttling client write bandwidth with the cgroup v2 I/O controller.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
