I’ve made a simple Block Allocator that can be easily used by extending a class called SmallObject, you can check it out here: https://bitbucket.org/nesdavid/cabinboypp/src/dbdf196317df1d81ccb2ea79f30b3e0a570cae84/include/blockalloc.h?at=default
I’ve tested this allocator allocating objects with ::new and ::delete and then using the new and delete from my SmallObject class and the results are pretty good, the allocator works almost twice as fast.
The thing is that when I wanted to test it with CCObjects it didn’t performed that well, what is more it even performed worse!
Trying to make some sense of it I prepared 2 simple tests. In one I have a SmallNode
class SmallNode : public CCNode, public SmallObject
and in the other one vanilla CCNodes
In the test where I use new and delete, SmallNode performs faster, as expected.
But when I use create() and release() all the performance gain was lost.
Do you have any idea of what kind of magic is the compiler doing that the gain I’ve measured from a simple new and delete disappears when I test it through create() and release()? or I just have to settle by the fact that I’m no longer fragmenting the heap?