[pool] Is it even possible to call release_memory() for map/list allocator pools portably?

I have a map, declared as: typedef std::pair<int, HintPage *> PageCachePair; typedef boost::fast_pool_allocator<PageCachePair> PageCacheAllocator; typedef std::map<int, HintPage *, std::less<int>, PageCacheAllocator> PageCache; The problem is when I try to call: boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(PageCachePair)>::purge_memory(); This always returns false. The real problem (of course) is that sizeof(PageCachePair) is incorrect. The real size is determined by the rebind mechanism for the actual map node struct. However, I have no idea how to portably determine that size. Is it even possible to do this? Scott

On 10/22/07, Scott <cheesy4poofs@cox.net> wrote:
I have a map, declared as:
typedef std::pair<int, HintPage *> PageCachePair; typedef boost::fast_pool_allocator<PageCachePair> PageCacheAllocator; typedef std::map<int, HintPage *, std::less<int>, PageCacheAllocator> PageCache;
The problem is when I try to call:
boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(PageCachePair)>::purge_memory();
This always returns false. The real problem (of course) is that sizeof(PageCachePair) is incorrect. The real size is determined by the rebind mechanism for the actual map node struct. However, I have no idea how to portably determine that size.
Is it even possible to do this?
I've ran into this before, and there are some old posts on the Mailing List about this. I can't remember the solution off the top of my head, so you may want to do a search, but I'm pretty sure there's no portable way around this. The big problem is that PageCache::allocator_type will still be identical to your typedef, and get_allocator won't help because you won't know the correct type to cast to. --Michael Fawcett

I've also run into this problem, but using list<>. I couldn't find anything else about this in the mailing list... (maybe I used the wrong keywords in the search?) Did someone find a portable solution? (i.e., without needing to recur to ugly hacks such as using list<>::_Node) Better yet... is there a portable way to use the "Object Usage" pool with STL containers, instead of the static one? Thanks in advance Edson On Oct 22, 2007 5:29 PM, Michael Fawcett <michael.fawcett@gmail.com> wrote:
On 10/22/07, Scott <cheesy4poofs@cox.net> wrote:
I have a map, declared as:
typedef std::pair<int, HintPage *> PageCachePair; typedef boost::fast_pool_allocator<PageCachePair> PageCacheAllocator; typedef std::map<int, HintPage *, std::less<int>, PageCacheAllocator> PageCache;
The problem is when I try to call:
boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(PageCachePair)>::purge_memory();
This always returns false. The real problem (of course) is that sizeof(PageCachePair) is incorrect. The real size is determined by the rebind mechanism for the actual map node struct. However, I have no idea how to portably determine that size.
Is it even possible to do this?
I've ran into this before, and there are some old posts on the Mailing List about this. I can't remember the solution off the top of my head, so you may want to do a search, but I'm pretty sure there's no portable way around this.
The big problem is that PageCache::allocator_type will still be identical to your typedef, and get_allocator won't help because you won't know the correct type to cast to.
--Michael Fawcett
participants (3)
-
Edson Tadeu
-
Michael Fawcett
-
Scott