Memory usage of Godot's various base classes

I was curious how many bytes e.g. a Node takes compared to a plain Object, so I modified the engine’s code to print the sizeof various types. This is on x86_64 Arch Linux, using gcc 15.1.1, but I think the results would be fairly representative of other platforms as well.

First, with target=editor, which enables various functions only useful when running the game from the editor:

Object: 376
RefCounted: 384
Resource: 576
Node: 1032
Node2D: 1408
Node3D: 1320
Control: 2504

Then with target=template_debug, which compiles with debug info but without editor-specific debugging tools:

Object: 328
RefCounted: 336
Resource: 504
Node: 976
Node2D: 1352
Node3D: 1240
Control: 2440

Finally, the one that really matters, target=template_release:

Object: 320
RefCounted: 328
Resource: 496
Node: 968
Node2D: 1344
Node3D: 1232
Control: 2432

As you can see, Node takes about twice as much memory as Resource, and three times as much as RefCounted. RefCounted seems to be a better default choice than Object, since the difference is very small, also in terms of performance.

I added Node2D, Node3D and Control only for completeness, since you typically don’t have extremely many of these – and if you do, you’ll run into bottlenecks elsewhere before these few kB start to matter.

Hopefully this will help someone decide whether to avoid using nodes for everything :slight_smile:

21 Likes

Hey - that’s very useful. Thanks for compiling that list.
I’m doing a research if moving from PySide6/Qt3d framework to Godot for my application would be a leaner option from the memory usage point of view and it feels like it would…

1 Like

Is this true? I ask since i have heard some people say that even the base object type is 4k bytes.

Those “some people” are very probably wrong. The results can vary a bit between platforms and compilers, but not by a factor of 10. If anyone has evidence of the contrary, let them post it here.

1 Like

I mean one of those has a lot of years of experience with godot and knows godot limits( it’s Lilly), so I’m not really sure, since she knows what she says. Still an object is 3 times heavier than a unity dots entity.

Numbers don’t lie. There is no gotchas or smoke and mirrors, it’s basic byte counting.

1 Like