Boost C++ Libraries: Ticket #290: perfomance: memory cleanup for pool takes too long https://svn.boost.org/trac10/ticket/290 <pre class="wiki">hi, In my project I use boost::pool because I have to instantiate millions of object at the beginning of the application, and only get rid of the at termination time. I noticed that when processing large data (which may require 1Gb memory for the application while it is running) the application may finish its processing approx after 10 seconds. the cleanup part (which consists only of calling the pool release methods on allocated objects) on the other hand, takes many minutes (I usually give up after 5 minutes) debugging the code i noticed that the while loop in the nextof function (of SIMPLE SEGREGATED STORAGE.HPP) takes many iterations. this leads me to the belief that the reason the cleanup takes too long is because trying to cleanup 1GB memory of million of objects at once causes pool to retain all its chunks in the hope of more allocations in the future which in turns causes it to waste all computation on running to the end of (endless) lists in the nextof function I will appreciate a suggestion on how to fix this until a more permanent solution is applied to the pool library thanks aviad aviadr@pob.huji.ac.il </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/290 Trac 1.4.3 nobody Thu, 22 Mar 2007 23:04:11 GMT <link>https://svn.boost.org/trac10/ticket/290#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/290#comment:1</guid> <description> <pre class="wiki">Logged In: NO If the objects are just allocated once at the beginning of the app, and then destroyed at the very end, it's a very simple memory management scenario. Why not just create a very simple allocator that just steps along a boost::array, allocating bytes from it? The allocator would never need to reuse data so the task is a lot simpler. Ideal would be for boost::poool to handle that, but this should get you out of trouble. -- Matthew </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Wed, 21 Nov 2007 01:19:08 GMT</pubDate> <title>component, description changed; severity set https://svn.boost.org/trac10/ticket/290#comment:2 https://svn.boost.org/trac10/ticket/290#comment:2 <ul> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">pool</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/290?action=diff&amp;version=2">diff</a>) </li> <li><strong>severity</strong> → <span class="trac-field-new">Problem</span> </li> </ul> Ticket Marshall Clow Wed, 21 Nov 2007 22:49:16 GMT status, resolution changed https://svn.boost.org/trac10/ticket/290#comment:3 https://svn.boost.org/trac10/ticket/290#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> I don't understand what the OP is talking about here: </p> <p> debugging the code i noticed that the while loop in the nextof function (of SIMPLE SEGREGATED STORAGE.HPP) takes many iterations. </p> <p> -- there's no loop in the nextof() function in that file. Closing. </p> Ticket contact.lipik@… Tue, 29 Jan 2008 13:22:47 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/290#comment:4 https://svn.boost.org/trac10/ticket/290#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">wontfix</span> </li> </ul> <p> Hi, I am experiencing the exact same problem, with latest version from SVN. The while loop referred to by the OP is in <em>simple_segregated_storage::find_prev</em>, which is called from <em>ordered_free</em>. There is a comment there that this is a slow function. My app allocates around 70MB, through <em>fast_pool_allocator</em> based maps, as well as pool_allocator based strings/vectors. Application shutdown takes ~10 minutes. The problem disappears if I stop using <em>pool_allocator</em> in strings &amp; vectors (<em>fast_pool_allocator</em> does not cause any issues). I'll try and attach some code to reproduce the problem tomorrow. Thanks </p> Ticket fkonvick Wed, 08 Apr 2009 15:37:14 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/290#comment:5 https://svn.boost.org/trac10/ticket/290#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> I also observed the problem, but there is a simple explanation. If you use MANY std::vector objects using boost::pool_allocator, then you might run into this problem. This is, AFAICT, by design - the vectors are just deallocated out of the "ideal" order. (You should not use other std containers with this allocator.) </p> <p> The solution is - just use std::allocator for std::vector (the performance is comparable). For the rest, use boost::fast_pool_allocator. </p> <p> (There are other solutions possible, but this is a bit OOT here.) </p> Ticket