Recursive Class Instance Size in Delphi

后端 未结 5 527
北海茫月
北海茫月 2021-01-14 02:17

Is there a way to get the actual size of a class instance in Delphi?

I know about the InstanceSize method of the TObject class but that method does not recursively i

5条回答
  •  囚心锁ツ
    2021-01-14 02:37

    Is there a way to get the total size of the class including its reference to other class instances?

    You just said it. The reference is a pointer; its size is 4 bytes. The value returned by InstanceSize is the number of bytes allocated for instance data of the class.

    myOtherVar2 might be nil, for example. But the nil pointer value would still occupy 4 bytes of memory.

提交回复
热议问题