A blender::Pool can construct and destruct elements without reordering. Freed items memory
will be reused by next allocations.
Elements are allocated in chunks to reduce memory fragmentation and avoid reallocation.
Differential D15894
BLI: Add new `blender::Pool` container Authored by Clément Foucault (fclem) on Sep 6 2022, 1:28 PM.
Details A blender::Pool can construct and destruct elements without reordering. Freed items memory Elements are allocated in chunks to reduce memory fragmentation and avoid reallocation.
Diff Detail
Event Timeline
Comment Actions Maybe it's a dumb question, but what benefit does a vector of chunks have over a single vector of elements?
Comment Actions The choice for a vector of chunks is multiple:
Comment Actions I was interested to see the new container, if possible, I will add my thought. Comment Actions Not my expertise, it might be a dumb question, but since Blender has a BLI_mempool, if this blender:Pool has similar usage (with advantages), would it be nice to replace the BLI_mempool code with this new one? (instead of having two similar implementations)? Comment Actions @Germano Cavalcante (mano-wii) Yes this is kind of a lightweight version of the BLI_mempool. However, this is a C++ implementation only and does not cover all the use cases of the mempool. This is meant to be a simple replacement for now but could be declined into IterablePool later if needed. @Iliya Katueshenock (Moder) I am not sure I get what you are trying to say. There is no real safety mechanism here because there is no fast way to make sure a given object is from this pool or is even still constructed. This would require more data and complexity to add this check and it would slow down the debug builds. I don't really need that right now but I do see its potential. | ||||||||||||||||||||||||||||||||||||||||||||||||