1
我嘗試在列表上使用boost :: fast_pool_allocator來管理內存分配。 下面是示例代碼,我有,如何釋放由boost fast_pool_allocator管理的內存?
boost::fast_pool_allocator<int> alloc;
std::list<int, boost::fast_pool_allocator<int>> data_pool(alloc);
data_pool.push_back(1);
data_pool.push_back(2);
data_pool.clear();
boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(int)>::purge_memory();
但purge_memory永遠不會釋放內存。我GOOGLE了一下,看到有人提到sizeof(int)對於列表節點來說大小不正確。
但是我怎樣才能得到正確的列表節點大小,使purge_memory工程?