=?UTF-8?B?w5ZuZGVyIEthbGFjxLE=?= <onderkal...@gmail.com> writes: > With PG 15 (rc1 or beta4), I'm observing an interesting memory pattern.
Yup, that is a leak. valgrind'ing it blames this call chain: ==00:00:16:12.228 4011013== 790,404,056 bytes in 60,800,312 blocks are definitely lost in loss record 1,108 of 1,108 ==00:00:16:12.228 4011013== at 0x9A5104: palloc (mcxt.c:1170) ==00:00:16:12.228 4011013== by 0x89F8D9: datumCopy (datum.c:175) ==00:00:16:12.228 4011013== by 0x9B5BEE: tuplesort_getdatum (tuplesortvariants.c:882) ==00:00:16:12.228 4011013== by 0x6FA8B3: ExecSort (nodeSort.c:200) ==00:00:16:12.228 4011013== by 0x6F1E87: ExecProcNode (executor.h:259) ==00:00:16:12.228 4011013== by 0x6F1E87: ExecMergeJoin (nodeMergejoin.c:871) ==00:00:16:12.228 4011013== by 0x6D7800: ExecProcNode (executor.h:259) ==00:00:16:12.228 4011013== by 0x6D7800: fetch_input_tuple (nodeAgg.c:562) ==00:00:16:12.228 4011013== by 0x6DAE2E: agg_retrieve_direct (nodeAgg.c:2454) ==00:00:16:12.228 4011013== by 0x6DAE2E: ExecAgg (nodeAgg.c:2174) ==00:00:16:12.228 4011013== by 0x6C6122: ExecProcNode (executor.h:259) ==00:00:16:12.228 4011013== by 0x6C6122: ExecutePlan (execMain.c:1636) and bisecting fingers this commit as the guilty party: commit 91e9e89dccdfdf4216953d3d8f5515dcdef177fb Author: David Rowley <drow...@postgresql.org> Date: Thu Jul 22 14:03:19 2021 +1200 Make nodeSort.c use Datum sorts for single column sorts Looks like that forgot that tuplesort_getdatum()'s result has to be freed by the caller. regards, tom lane