-
Notifications
You must be signed in to change notification settings - Fork 208
Description
Hi,
I have the following code:
using memory_pool = foonathan::memory::memory_pool_collection<memory::node_pool,
memory::identity_buckets,
memory::fixed_block_allocator<memory::default_allocator>>;
class something {
public:
void init();
private:
unique_ptr<memory_pool> _object_pool;
}
void something::init() {
size_to_allocate = 1024*1024;
initializer_list<size_t> node_sizes = {memory::list_node_size<pair<init, int>>::value,
memory::unordered_map_node_size<int, list<pair<int,int>>::iterator>::value,
sizeof(memory::unordered_map<int, list<pair<int,int>>::iterator>::iterator)};
auto max_node_size = std::max(node_sizes);
_object_pool = make_unique<memory_pool>(max_node_size, size_to_allocate);
_object_pool->allocate_node(32);
}
When executing this code an exception is thrown:
[foonathan::memory] Allocator foonathan::memory::fixed_block_allocator (at 0x600001ed4158) ran out of memory trying to allocate 0 bytes.
Tried also to replace the _object_pool->allocate_node(32); with _object_pool->get_allocator().allocate_block(); and got the same exception.
This is a simplification of the code that I want to achieve at the end which is using this pool collection for a couple of containers (one list and one map as can be seen). My understanding is that the pool collection will allocate the block in the first call for allocate_node/allocate_array - but seems like this is not the case. How am I supposed to trigger the actual memory allocation? Or am I completely off?
Thanks.