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
Construct one MyClass1 object and a million MyClass2 such that each MyClass2 points to the same MyClass1.
How much memory does each MyClass2 take? 12.000012 bytes?
How much memory does a circular list take? Infinity as you can keep chasing pointers for ever?
In languages with pointers, a naive recursive size-of algorithm isn't useful in general. You need to write your own algorithm which embodies knowledge about the aggregation/composition, sharing and recursive references specific to how you're using the objects.