Is there a way to free all of the objects in a boost::singleton_pool
at once?
I see that I have access to these methods:
static void free(void *const);
static void ordered_free(void *const);
static void free(void *const, const size_type);
static void ordered_free(void *const, const size_type);
I imagine I could use them to free all the objects by iterating through them manually. However, is there any way to say "free all the objects" so that the pool becomes completely free again?
Essentially I would like something like purge_memory()
but that wouldn't release the memory back to the system, but keep it allocated in the pool.
The reason for this is that I build a large object inside the pool (~2GB) which I want to get rid of very quickly and start building a new one. Calling purge_memory()
currently takes around 2s and also releases memory to the system (in diagnostics, or task manager, you can see the Process Memory decreasing). My hope is that by simply freeing things in the pool without actually deallocating, I can blast away the first object very quickly and start building the next.