Boost logo

Boost :

Subject: Re: [boost] [pool] Objects of varying sizes
From: Alex Perry (Alex.Perry_at_[hidden])
Date: 2012-06-27 07:10:52


Robert Dailey on 26 June 2012 19:03 wrote :

>So are you saying it isn't beneficial or practical to use boost::pool to allocate chunks of varying sizes, and that the Windows Memory Manager is better suited?

For me the major benefit of an arena allocator like boost:pool is to avoid memory fragmentation which can happen with the general purpose (variable sized) heap allocations (are provided by compiler ie gcc or VC etc AFAIK rather than using Windows Memory Manager directly).

Ie you know that all these objects are probably sharing some lifetime - avoid too much fragmentation by allocating them from some easily reused larger block by some mechanism such as boost pool.

If you have different sized objects then calculate the smallest "sensible" size for these allocations and set the pool up with this granularity and then allocate as many of these "grains" as you need for each object.

You still get the separation from the general purpose heap (and also a fast destruct of the entire pool without calling individual destructors if required which can be a win in some scenarios_

HTH

Alex


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk