Skip site navigation (1) Skip section navigation (2)

Re: Memory leak on hashed agg rescan

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Neil Conway" <neil(dot)conway(at)gmail(dot)com>
Cc: "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Memory leak on hashed agg rescan
Date: 2008-10-16 12:26:47
Message-ID: 10455.1224160007@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
"Neil Conway" <neil(dot)conway(at)gmail(dot)com> writes:
> I noticed a minor leak in the per-query context when ExecReScanAgg()
> is called for a hashed aggregate. During rescan, build_hash_table() is
> called to create a new empty hash table in the aggcontext. However,
> build_hash_table() also constructs the "hash_needed" column list in
> the per-query context, so repeated calls of build_hash_table() result
> in leaking this memory for the duration of the query.

> Attached is a patch that fixes this by only constructing "hash_needed"
> if it doesn't already exist. I also bms_free'd the temporary BMS that
> is created, although that's pretty harmless.

It would probably be cleaner to take that logic out of build_hash_table
altogether, and put it in a separate function to be called by
ExecInitAgg.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Simon RiggsDate: 2008-10-16 12:55:47
Subject: Re: Deriving Recovery Snapshots
Previous:From: KaiGai KoheiDate: 2008-10-16 10:57:58
Subject: Re: Updates of SE-PostgreSQL 8.4devel patches

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group