Given the following answer to a question related to it ( https://stackoverflow.com/a/166269/ ), are object references counted in Windows-based Delphi applications?
i.e:.
Q1A Does the next object have a reference count of 2 after the second statement?
o1 := TMyObject.Create; o2 := o1;
Q1B . Following the above, setting o1 to nil , reset the reference count to 1?
o1 := nil;
Q1C Following on again, setting o2 to nil , reset the reference count to 0?
o2 := nil;
Q1D Moving forward, if the above is correct, and now the object has a reference count of 0, I understand that the compiler will NOT automatically free the object ( o2.Free should have been called earlier on o2 := nil above to prevent memory leak). Remember that I'm talking about a Windows target, not a mobile target with automatic link counting (ARC).
Q1E If link counting does not automatically free up memory associated with an object, then what exactly is the reference counting point in Delphi (for example, does it help track memory leaks)?
source share