Memory

pg_backend_memory_contexts

Also called: backend memory contexts view, memory context introspection

pg_backend_memory_contexts is a system view (PostgreSQL 14+) listing every memory context in the current backend, name, parent, depth level, and total/used/free bytes. It exposes the live context tree so you can see exactly where a backend's memory is going.

What this means

A system view (PG14+) that lists every memory arena in your current backend, its name, its parent, and how many bytes it's holding, used and free. It exposes the live arena tree, so when a backend's memory balloons you can see exactly which part is eating it.

Why it matters operationally

It turns "this connection is using 2 GB" into "its CacheMemoryContext is 1.8 GB." Paired with pg_log_backend_memory_contexts(pid), which dumps another backend's contexts to the server log, it is the primary tool for diagnosing per-backend memory bloat.

Related & next

Memory contexts explainedMemory context, what this view listsBackend process, whose memory it shows

← All glossary terms · GUC reference · Error catalog