Re: Memory leak in vac_update_relstats ? - Mailing list pgsql-hackers

From NikhilS
Subject Re: Memory leak in vac_update_relstats ?
Date
Msg-id d3c4af540707200547w7d972cb5v3155932212bf6be2@mail.gmail.com
Whole thread Raw
In response to Re: Memory leak in vac_update_relstats ?  (NikhilS <nikkhils@gmail.com>)
Responses Re: Memory leak in vac_update_relstats ?
List pgsql-hackers
Hi,

That's the beauty of memory contexts for small allocations. But because of the 'convenience' of memory contexts we sometimes tend to not pay attention to doing explicit pfrees. As a general rule I think allocations in TopMemoryContext should be critically examined. I was bitten by this undue bloat recently while developing some code and valgrind is not of much help in such cases because of this very beauty of memory contexts :).


One specific case I want to mention here is hash_create(). For local hash tables if HASH_CONTEXT is not specified, they get created in a context which becomes a direct child of TopMemoryContext. Wouldn't it be a better idea to create the table in CurrentMemoryContext?

If hash_destroy() is not explicitly invoked, this can cause a lot of bloat especially if the intention was to use the hash table only for a while.

Regards,
Nikhils

Regards,
Nikhils


--
EnterpriseDB               http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: NikhilS
Date:
Subject: Re: Memory leak in vac_update_relstats ?
Next
From: "Pavan Deolasee"
Date:
Subject: MAXIMUM_ALIGNOF on Windows-32