Re: [Boost-bugs] [Boost C++ Libraries] #1252: [pool] severe overhead with unaligned sizes.

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #1252: [pool] severe overhead with unaligned sizes.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-09-22 20:18:32

#1252: [pool] severe overhead with unaligned sizes.
  Reporter: phrosty_at_[hidden] | Owner: marshall
      Type: Bugs | Status: assigned
 Milestone: Boost 1.37.0 | Component: pool
   Version: Boost 1.34.1 | Severity: Problem
Resolution: | Keywords: pool
Changes (by cnewbold):

 * cc: cnewbold (added)


 Here are my thoughts...

 I believe that the design outlined in the linked documents is sound,
 including the use of LCM to find the chunk size which will satisfy the
 alignment requirements of the free list pointer and block size.

 The problem with the original design is using requested_size in the LCM
 computation. Just because I asked for chunks of X bytes does not mean that
 each chunk must be aligned on an X byte boundary.

 Predicate 2 of the "Guaranteeing Alignment" document quotes language from
 5.3.4/10 of the C++ standard indicating that memory obtained in a 'new'
 expression must be aligned on a boundary that is a multiple of that
 required by the type with the most stringent alignment requirement. On
 most platforms, this is going to be double, or long long, or maybe long

 The point being that the "worst-case" scenario is that the programmer
 tries to lay down a structure at the start of a chunk obtained from the
 pool and that structure has an element of such a type.

 This is exactly what malloc() or operator new() does. I do not think that
 the pool needs to do anything more.

 The proposed change in this ticket, however, is not correct. It does not
 account for the possibility that some type may have a more stringent
 alignment requirement than the free-list pointer and/or block size value.

Ticket URL: <>
Boost C++ Libraries <>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC