Closed GWRon closed 9 months ago
Yes, it is used for Reflection. The debug scope/debug decls describe the shape of the type and its members and BRL.Reflection uses them to build its TTypeId and TMember instances.
Doesn't that mean that each object instance you create (in release builds) also occupies (additionally) a bit memory whose amount depends on the amount of methods/fields a type has
No, that's not the case. One BBDebugScope instance and one BBClass instance is created per type, and the latter contains a pointer to the former ((BBDebugScope*)&_m_untitled1_TTest_scope
). In the generated .h file (included at the top of the .c file you quoted), you should find this:
struct _m_untitled1_TTest_obj {
struct BBClass__m_untitled1_TTest* clas;
BBINT __m_untitled1_ttest_x;
};
That's what the actual instances of TTest look like - a pointer to the BBClass instance plus the contents of all the fields. The debug scope doesn't take up any additional memory per instance.
Thanks for the explanation
Will close now (as it is answered)
Heya,
This question goes out targeting most probably @HurryStarfish and @woollybah.
I wrote a small sample to check if
self.x = 20
vsx = 20
create the same code (yes it does, so writingself. ...
comes without costs by adding some maybe improved readability regarding local and instance variables). Ok ... distracting ancillary information aside...This code here:
Generates this C Code:
And I am wondering why a release build has to contain
struct BBDebugScope_3 _m_untitled1_TTest_scope ={
... Doesn't that mean that each object instance you create (in release builds) also occupies (additionally) a bit memory whose amount depends on the amount of methods/fields a type has ((BBDebugScope*)&_m_untitled1_TTest_scope, sizeof(struct _m_untitled1_TTest_obj),
) ?The question now: is this there for some specific reason (reflection stuff or so) or could the types be "thinned out" by removing the debug stuff (eg only using an "no-debug"-struct which all types share in release builds - only sacrificing some bytes then) ?