Add tracking of backend memory allocated to pg_stat_activity

From: Reid Thompson <reid(dot)thompson(at)crunchydata(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: reid(dot)thompson(at)crunchydata(dot)com
Subject: Add tracking of backend memory allocated to pg_stat_activity
Date: 2022-08-31 16:03:06
Message-ID: 67bb5c15c0489cb499723b0340f16e10c22485ec.camel@crunchydata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hackers,

Attached is a patch to
Add tracking of backend memory allocated to pg_stat_activity
   
This new field displays the current bytes of memory allocated to the
backend process.  It is updated as memory for the process is
malloc'd/free'd. Memory allocated to items on the freelist is included
in the displayed value.  Dynamic shared memory allocations are included
only in the value displayed for the backend that created them, they are
not included in the value for backends that are attached to them to
avoid double counting. On occasion, orphaned memory segments may be
cleaned up on postmaster startup. This may result in decreasing the sum
without a prior increment. We limit the floor of backend_mem_allocated
to zero.

--
Reid Thompson
Senior Software Engineer
Crunchy Data, Inc.

reid(dot)thompson(at)crunchydata(dot)com
www.crunchydata.com

Attachment Content-Type Size
001-pg-stat-activity-backend-memory-allocated.patch text/x-patch 26.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-08-31 16:04:44 Re: SQL/JSON features for v15
Previous Message Dave Page 2022-08-31 16:02:33 Re: Tracking last scan time