|
Boost Users : |
From: Soren Soe (Soren.Soe_at_[hidden])
Date: 2007-04-05 15:01:10
Hi,
I am trying to replace an old implementation of a small object memory
allocator with boost::pool. I have noticed that boost::pool uses quite
a bit more memory for certain requested_size than the allocator I am
trying to replace.
After looking at the code and reading the Guaranteeing Alignment
<http://www.boost.org/libs/pool/doc/implementation/alignment.html>
document, I am wondering why boost::pool::alloc_size() have to be
lcm(sizeof(void*), sizeof(size_type), requested_size)? Lots of bytes
can be wasted in the chunks returned to user when requested_size is not
a multiple of min_alloc_size (lcm(sizeof(void*), sizeof(size_type))).
I would think the requested_size alignment could be the first multiple
of min_alloc_size that is larger than requested_size. For example, the
convoluted example in the alignment document has requested_size==7,
sizeof(void*)==3, and sizeof(size_type)==5. Currently alloc_size()
returns lcm(3,5,7)==105, but since min_alloc_size is lcm(3,5)==15, I
think requested_size alignment could be 15 bytes, rather than the 105
bytes.
Another way to look at this. If requested_size was changed to 15, then
the current implementation of alloc_size() would return 15 bytes
(lcm(3,5,15)==15), so why the huge penalty when requested size is 7?
Am I missing something?
Thank you.
Soren
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net