On Thu, 2003-11-13 at 16:26, Cliff Woolley wrote: > On Thu, 13 Nov 2003, Norman Tuttle wrote: > > > How do the pools define "if possible" in your wording below (i.e., how > > would the pool know when to reuse memory)? > > It's kind of complicated, so I don't know how well I can explain it off > the top of my head (Sander, feel free to jump in here :), but it keeps > freelist buckets of varying power-of-two sizes, and if it finds one of the > appropriate size, it will use it.
The allocator keeps freelists of multiples of 4k blocks actually ;) > But there are two levels of things going on, too, because the allocator > hands out blocks of a certain size, which the pools then divide up into > smaller blocks... Pools get blocks from the allocator. Pools then hand out the requested memory to the caller. They hold on to the 'surplus' for the next allocation. On a pool clear, all used blocks return to the allocator (except for the block containing the pool itself (8k)). > Oy. > > Sander? Help me out. :) You know what, this question comes up reasonably frequently. Enough for me to start writing a document on this. I'll post a URL later on. Sander