Re: [PATCHv4 10/12] notes.c: Implement simple memory pooling of leaf nodes
- From
Johan Herland <johan@herland.net>
- Date
- Aug 27, 2009, 09:49 UTC
- Message-ID
- <200908271149.11003.johan@herland.net>
- In-Reply-To
- <81b0412b0908270039l7a937c3bmd745274c71526ce1@mail.gmail.com>
On Thursday 27 August 2009, Alex Riesen wrote:
Show 7 quoted lines
> On Thu, Aug 27, 2009 at 03:43, Johan Herland<johan@herland.net> wrote: > > 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, <johan@herland.net> www.herland.net