Boost C++ Libraries: Ticket #7106: multi_array::resize switches to default-constructed allocator https://svn.boost.org/trac10/ticket/7106 <p> I've run into this with 1.46 but eyeballing the code on trunk it doesn't seem to have changed. </p> <p> The implementation of <code>resize</code> starts like this: </p> <pre class="wiki"> // build a multi_array with the specs given multi_array new_array(ranges,this-&gt;storage_order()); </pre><p> However, no allocator is passed to this constructor. If <code>*this</code> has a non-default allocator, then it will not get used to allocate the resized storage, and furthermore, the default allocator in new_array will get swapped in to <code>*this</code>, wiping out the custom allocator. </p> <p> This can be fixed by changing this line to </p> <pre class="wiki"> multi_array new_array(ranges,this-&gt;storage_order(),allocator_); </pre><p> so that the new array uses the same allocator as the current one. </p> <p> I'll attach a test case that demonstrates the issue by using an allocator class where instances are named and report the allocations they make (I'm using a more complex version of this to track memory usage, which is where I hit the bug). It currently reports </p> <pre class="wiki">Allocated 17 bytes [name = vector] Allocated 0 bytes [name = multi_array] Allocated 15 bytes [name = default] </pre><p> but with the fix applied it reports </p> <pre class="wiki">Allocated 17 bytes [name = vector] Allocated 0 bytes [name = multi_array] Allocated 15 bytes [name = multi_array] </pre><p> It is the final line where the resize is taking place. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7106 Trac 1.4.3 bmerry@… Mon, 09 Jul 2012 14:01:24 GMT attachment set https://svn.boost.org/trac10/ticket/7106 https://svn.boost.org/trac10/ticket/7106 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">multi_array-alloc.cpp</span> </li> </ul> Ticket