pgsql: Fix memory leak in LogStandbySnapshot().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix memory leak in LogStandbySnapshot().
Date: 2013-06-04 18:59:25
Message-ID: E1UjwS5-0000G4-CW@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix memory leak in LogStandbySnapshot().

The array allocated by GetRunningTransactionLocks() needs to be pfree'd
when we're done with it. Otherwise we leak some memory during each
checkpoint, if wal_level = hot_standby. This manifests as memory bloat
in the checkpointer process, or in bgwriter in versions before we made
the checkpointer separate.

Reported and fixed by Naoya Anzai. Back-patch to 9.0 where the issue
was introduced.

In passing, improve comments for GetRunningTransactionLocks(), and add
an Assert that we didn't overrun the palloc'd array.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/c28bfb35ef6ce9e9d82da00008554d0fc9c4a7fc

Modified Files
--------------
src/backend/storage/ipc/standby.c | 7 +------
src/backend/storage/lmgr/lock.c | 16 +++++++++++++---
2 files changed, 14 insertions(+), 9 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2013-06-04 19:42:32 pgsql: Add ARM64 (aarch64) support to s_lock.h.
Previous Message Heikki Linnakangas 2013-06-04 15:53:56 pgsql: Fix off-by-one in pg_xlogdump -r option.