3 ms·
gdscript is dynamically typed. If you have the large arrays of structs common in gamedev, then all data members are boxed, significantly increasing memory usage
by steeleduncan 4y ago
gdscript is dynamically typed. If you have the large arrays of structs common in gamedev, then all data members are boxed, significantly increasing memory usage compared to something like C#.
- unsafecast 4y agoC# objects are boxed too.
- jbluepolarbear 4y agoBoxing is taking a Value Type (struct, int, enum, etc) and converting it to an Object. So Objects aren’t boxed.
- unsafecast 4y agoApparently we have different definitions of boxing. To me, and I've always used it (and seen it used) like this, a boxed value is a value that's stored on the heap and passed as a pointer. Maybe C# has a different definition?
- steeleduncan 4y agoNo, from the C# docs[1] - Boxing is the process of converting a value type to the type object or to any interface type implemented by this value type [1] https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/boxing-and-unboxing https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...
- unsafecast 4y agoRight, so then in C# a boxed value is an object as far as I can tell.
- jbluepolarbear 4y agoThat’s correct, but not what you said. You said objects are boxed. Values are boxed to create a reference by wrapping it in an object, objects are already reference types so there’s no boxing.
- unsafecast 4y agoI'm not extremely familiar with C# objects, but I think I get the confusion now. My point was that objects are boxed values, and that most things in C# are (to my knowledge) objects. I guess I used slightly the wrong words.