Re:Joint Allocations in C++
by svalorzen on Monday September 14, 2015 @06:15AM
(#10214385)
I believe that the main problem is not allocation time (games already have loading times, that's not a problem), but fast access and not breaking the cache.
[ Parent
| on HN ]
The title of the first slide in the video is "Heap allocations are expensive!" And using a pool the way I'm proposing does not fragment the heap. It might be slightly worse if you serially touch a lot of Meshes which have only a few vertices and edges each, but this is a corner case and a trade-off anyway.
Meshes are typically quite big. Moving two small blocks of data together helps to improve cache behaviour as the two blocks can then fit in a single cache line. Moving two giant blocks of data closer together is not going to make much difference, because they probably span hundreds or thousands of cache lines anyways.