<div dir="ltr">Hi : <br><br>I use&nbsp; fast_pool_allocator and it seems not<br>release memory even I explicitly call&nbsp; <br><br>&nbsp;boost::singleton_pool&lt;boost::fast_pool_allocator_tag, sizeof(int)&gt;::release_memory();<br><br>
out put<br>1. MEM USAGE = 11 MB, <br>2. MEM USAGE = 35<br>2. MEM USAGE = 35<br>2. MEM USAGE = 35<br>3. MEM USAGE = 35<br><span style="color: rgb(204, 0, 0);">4. MEM USAGE = 35&nbsp; &lt;&lt;&lt;--- memory is not released!!!</span><br>
<br><br>Any suggestions are welcomed.<br><br>-Todd<br><br><br>--- BEGIN ----<br clear="all">#include &lt;boost/pool/pool_alloc.hpp&gt;<br>#include &lt;list&gt;<br><br><br>using namespace std;<br>using namespace boost;<br>
<br>#include &quot;memusage.cpp&quot;&nbsp; &lt;&lt;-- f<span style="color: rgb(255, 0, 0);">unction to call Unix &#39;top&#39;</span><br><br>//--------------------------------------------------<br>void func()<br>{<br><br>&nbsp; list&lt;int, fast_pool_allocator&lt;int&gt; &gt; v;<br>
&nbsp; //&nbsp; list&lt;int&gt; v;<br>&nbsp; for (int i = 0; i &lt; 1000000; ++i) {<br>&nbsp;&nbsp;&nbsp; v.push_back(i);<br>&nbsp; }<br><br>&nbsp; printf(&quot;2. MEM USAGE = %d\n&quot;, getMemUsage());<br><br>}<br><br><br>//--------------------------------------------------<br>
int main(int argc, char **argv)<br>{<br><br>&nbsp; printf(&quot;1. MEM USAGE = %d\n&quot;, getMemUsage());<br>&nbsp; func();<br>&nbsp; func();<br>&nbsp; func();<br>&nbsp; /// Exiting the function does NOT free the system memory allocated by the pool allocator<br>
&nbsp; // You must call<br>&nbsp; //&nbsp; boost::singleton_pool&lt;boost::pool_allocator_tag, sizeof(int)&gt;::release_memory()<br>&nbsp; // in order to force that<br>&nbsp; printf(&quot;3. MEM USAGE = %d\n&quot;, getMemUsage());<br><span style="color: rgb(255, 0, 0);">&nbsp; boost::singleton_pool&lt;boost::fast_pool_allocator_tag, sizeof(int)&gt;::release_memory();</span><br>
&nbsp;<br>&nbsp; printf(&quot;4. MEM USAGE = %d\n&quot;, getMemUsage());<br>&nbsp; <br>&nbsp; return 1;<br>&nbsp; <br>} <br><br>// from boost doc<br>// If you are seriously concerned about performance,<br>// use fast_pool_allocator when dealing with containers such as std::list,<br>
// and use pool_allocator when dealing with containers such as std::vector.<br><br>-- END -- <br><br>
</div>

