CCNode and block allocator

CCNode and block allocator
0.0 0



I’ve made a simple Block Allocator that can be easily used by extending a class called SmallObject, you can check it out here:

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?


What object Pooling methods does coocs2d-x support?

Can you share a complete code of the testbed? There are no tests with Cocos2d-x in the repository.

There are 2 functions testNewAndDelete and testCreateAndRelease. The new/delete pair is faster using SmallObject but the create/release is not.


Well, actually this is not a complete testbed and I have no time for gathering all the required pieces of code.

After a quick glance at the snippet I wonder how does the testCreateAndRelease even work, since you are releasing the object without retaining it before.
I also don’t think that 1000 objects and 1 iteration is enough to get more or less precise results.


It works the same way the Performance Test that comes within the cocos2dx Samples…