Boost logo

Boost Users :

Subject: Re: [Boost-users] custom allocators Re:pool_alloc
From: B Hart (bhartsb_at_[hidden])
Date: 2010-03-17 16:12:32


Sorry, I don't get you...as I understand the pool is a singleton, and
once out of scope I would assume all the memory for the set is
released back to the OS. Therefore what is the purpose of
release_memory()...maybe I don't understand pool. And then "internal
node type"...what is that?

On Wed, Mar 17, 2010 at 11:21 AM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> AMDG
>
> B Hart wrote:
>>
>> I am not understanding the use of pool with std::set.  i.e. the
>> release_memory() function referenced in last example shown on:
>> http://www.boost.org/doc/libs/1_42_0/libs/pool/doc/interfaces.html
>> seems to do nothing.
>>
>> I call GetProcessMemoryInfo() and don't see any change after the set
>> has gone out of scope.
>>
>> maybe someone could relate what happens to the allocated memory when
>> set goes out of scope and
>> release_memory() isn't called versus what happens when set goes out of
>> scope and
>> release_memory() is called.
>>
>> I want to do something like:
>>
>> 1.std::set<unsigned int, std::less<unsigned int>,
>> boost::pool_allocator<unsigned int>> v;
>> 2. for(int i=0; i<(K); i++)
>>       {
>>               v.insert(i);
>>
>>       }
>> 3. use v
>> 4. release_memory() on v //dump all set elements in one action. Note,
>> without custom allocator this is very slow for large sets.
>> 5. repeat 1-4 with a new set
>>
>
> std::set rebinds the allocator to its internal node type.  Thus,
> the allocator actually used by the set is using a different underlying
> pool than v.
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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