The following article on dynamic arrays in Delphi says that you allocate a dynamic array using the SetLength()
function.
myObjects : array of My
Setting an object reference to nil
does NOT free it. It simply decrements the internal reference count. When that reference count hits 0, the memory is freed or available for freeing.
So doing:
Obj.Free
Obj := nil;
isn't going to free it twice at all. It's going to free it once and set the Obj pointer to null.
For strings, the reference count used to be stored a an offset of 2 words before the first element and the size was stored 1 word before the first element. If it is constant, the reference count was usually -1. Not sure if this is still the case.