Fix a gradual memory leak in ExecReScanAgg(). Because the aggregation
authorNeil Conway <neilc@samurai.com>
Wed, 8 Aug 2007 18:06:58 +0000 (18:06 +0000)
committerNeil Conway <neilc@samurai.com>
Wed, 8 Aug 2007 18:06:58 +0000 (18:06 +0000)
commit9c40c734e4eaf8203fdaadf4a6950adde11eaafa
tree1102480b5f505457b3b1e410866fa5a48fc4183c
parentff5609746ebb723ed16b30118c6adbc343ad1e3e
Fix a gradual memory leak in ExecReScanAgg(). Because the aggregation
hash table is allocated in a child context of the agg node's memory
context, MemoryContextReset() will reset but *not* delete the child
context. Since ExecReScanAgg() proceeds to build a new hash table
from scratch (in a new sub-context), this results in leaking the
header for the previous memory context. Therefore, use
MemoryContextResetAndDeleteChildren() instead.

Credit: My colleague Sailesh Krishnamurthy at Truviso for isolating
the cause of the leak.
src/backend/executor/nodeAgg.c