Godot Version
4.3
Question
In most programming languages, you can choose between an int8, int32, etc.
Is this possible in Godot? I really don’t need a 64bit int for what I’m doing so it’d be nice to be able to reduce ram usage.
4.3
In most programming languages, you can choose between an int8, int32, etc.
Is this possible in Godot? I really don’t need a 64bit int for what I’m doing so it’d be nice to be able to reduce ram usage.
There’s probably a lot of other things eating up ram, you can specify integer size in most any language you want if you write your code as a GDExtension.
The thing is, I need a moderately sized array that stores a material type, and a color for each point in the array. 128 bits per point is massive and unnecessary.
You can use a packedbytearray, which basically stores single bytes as elements in an array
if i may advertise my own script you can use for writing to a packedbytearray:
I recommend you not do this unless you have a very good reason for it. Modern processors are 64-bit processors. They will actually process numbers stored in smaller amounts of bits (32-bit, 16-bit, 8-bit) slower. So you will incur a performance hit. Having said that, if you’re targeting a device that has a small RAM limit, go bananas.
I’m mainly posting this for people coming along who think they need to do optimizations like this, but aren’t exactly sure why. It’s a lot of extra work and if you do not know what you’re doing, you will end up with more complex code and performance issues to debug.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.