Archive 17/01/2023.

Custom memory allocation

mohamed.chit

It is believed that default C++ memory allocation to be slow, using new/delete without adding any implementation would have some penalties on performance.
We would like to use our custom memory allocators to use them to allocate Urho3d objects, is that possible? I see in Urho3d (RefCounted.cpp), it is hard coded (delete this).

I am not sure if it is possible to overload the new/delete operators (as far as I know, it should be done within the class declaration).
Doesn’t Urho3d define an interface for Memory/Object allocation ?

how is it possible to use a custom memory allocater.

RefCounted instance at constructor does allocate “new RefCount()”, that looks very expensive, doesn’t that effect on Urho3d performance!

it would be great to have some advice, hint about this.

regards

SirNate0

As far as I’m aware it does not. BUT…

which you are free to edit since you have the source code. If you wanted it to apply to all classes derived from Urho3D::Object you could probably put it in the URHO3D_OBJECT macro.

Though it would surprise me if you got much of a performance enhancement from these changes, unless you are creating/destroying thousands (millions?) of objects every frame. (I’m no expert and I’ve never tried myself, so feel free to experiment, I would welcome a more concrete benchmark over my speculation).

1vanK

At the moment, I believe that the bottleneck is a sending of messages, which is used quite heavily inside the engine.You can use 99_Benchmark.exe > Molecules for test. In addition, we need a possibility of multiple handlers for each event: https://github.com/urho3d/Urho3D/issues/2907. PR are welcome

vmost

You could check out this discussion I started.