Memory leak in nodeAgg
| От | Neil Conway |
|---|---|
| Тема | Memory leak in nodeAgg |
| Дата | |
| Msg-id | 1186435268.16321.37.camel@dell.linuxdev.us.dell.com обсуждение исходный текст |
| Ответы |
Re: Memory leak in nodeAgg
Re: Memory leak in nodeAgg |
| Список | pgsql-patches |
Attached is a patch that fixes a gradual memory leak in ExecReScanAgg(),
when the AGG_HASHED strategy is used:
* the aggregation hash table is allocated in a newly-created
sub-context of the agg's aggcontext
* MemoryContextReset() resets the memory allocated in child
contexts, but not the child contexts themselves
* ExecReScanAgg() builds a brand-new hash table, which allocates
a brand-new sub-context, thus leaking the header for the
previous hashtable sub-context
The patch fixes this by using MemoryContextDeleteAndResetChildren(). (I
briefly looked at other call-sites of hash_create() to see if this
problem exists elsewhere, but I didn't see anything obvious.)
We run into the leak quite easily at Truviso; with a sufficiently
long-lived query in vanilla Postgres, you should be able to reproduce
the same problem.
Credit: Sailesh Krishnamurthy at Truviso for diagnosing the cause of the
leak.
-Neil
Вложения
В списке pgsql-patches по дате отправления: