Re: [PATCHv4 10/12] notes.c: Implement simple memory pooling of leaf nodes
From: Johan Herland <hidden>
Date: 2016-06-15 22:47:19
On Thursday 27 August 2009, Alex Riesen wrote:
On Thu, Aug 27, 2009 at 03:43, Johan Herland[off-list ref] wrote:quoted
When allocating a new memory pool, the older pool is leaked, but this is no worse than the current situation, where (pretty much) all leaf_nodes are leaked anyway.Could you return the unused nodes back into the mempool? By making the pool a preallocated list, perhaps?
Yes, maintaining a free-list is certainly possible. However, the number of free()d leaf_nodes is relatively small (only subtree entries are free()d after unpacking them into the tree structure), so I'm not sure it pays off, runtime-wise.
And then it is trivial to provide a deallocation function for the mempool, which something really concerned about the memleak can call (like when or if libgit get more usable in an application context).
Yes, I plan to provide a free_notes() function that free()s all the memory associated with the notes data structure. This would of course keep references to all the mempools, and deallocate them (along with all the int_nodes). ...Johan -- Johan Herland, [off-list ref] www.herland.net