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

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

It's palloc'd in the current memory context, so it's not serious. It'll
be freed at the end of the transaction, if not before that. That's the
beauty of memory contexts; no need to worry about small allocations like
that.

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 :).

Regards,
Nikhils

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

pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Memory leak in vac_update_relstats ?
Next
From: NikhilS
Date:
Subject: Re: Memory leak in vac_update_relstats ?