Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc556b29

Browse files
author
Neil Conway
committed
Fix a gradual memory leak in ExecReScanAgg(). Because the aggregation
hash table is allocated in a child context of the agg node's memorycontext, MemoryContextReset() will reset but *not* delete the childcontext. Since ExecReScanAgg() proceeds to build a new hash tablefrom scratch (in a new sub-context), this results in leaking theheader for the previous memory context. Therefore, useMemoryContextResetAndDeleteChildren() instead.Credit: My colleague Sailesh Krishnamurthy at Truviso for isolatingthe cause of the leak.
1 parentaf1022d commitc556b29

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎src/backend/executor/nodeAgg.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
* Portions Copyright (c) 1994, Regents of the University of California
6262
*
6363
* IDENTIFICATION
64-
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.152 2007/04/02 03:49:38 tgl Exp $
64+
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.153 2007/08/08 18:07:05 neilc Exp $
6565
*
6666
*-------------------------------------------------------------------------
6767
*/
@@ -1646,8 +1646,14 @@ ExecReScanAgg(AggState *node, ExprContext *exprCtxt)
16461646
MemSet(econtext->ecxt_aggvalues,0,sizeof(Datum)*node->numaggs);
16471647
MemSet(econtext->ecxt_aggnulls,0,sizeof(bool)*node->numaggs);
16481648

1649-
/* Release all temp storage */
1650-
MemoryContextReset(node->aggcontext);
1649+
/*
1650+
* Release all temp storage. Note that with AGG_HASHED, the hash table
1651+
* is allocated in a sub-context of the aggcontext. We're going to
1652+
* rebuild the hash table from scratch, so we need to use
1653+
* MemoryContextResetAndDeleteChildren() to avoid leaking the old hash
1654+
* table's memory context header.
1655+
*/
1656+
MemoryContextResetAndDeleteChildren(node->aggcontext);
16511657

16521658
if (((Agg*)node->ss.ps.plan)->aggstrategy==AGG_HASHED)
16531659
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp