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

Reply via email to