However, TP objects don't apply here, since their destructors are not called automatically (only explicitly with "Dispose (pointer, destructor (...))"), which I consider a major drawback of the TP object model, BTW.
What model do you think which allows automatic destructors. I have heard of three - The old TP objects declared on stack (and thus automatically freed at the exit of the procedure) with var o: tObject ... The drawback is that it does not allow inheritance and polymorphism (only encapsulation), because these need size changes. This makes them nearly useless.
- Garbage collector "a la Lisp". It has no sensible way to decide when to call it. Usually it was called "when memory is exhausted", a situation difficult to decide with nowadays shared memories systems. The program using it hanged for very long times when it started. A very bad compromise between lazziness and efficiency.
- reference count, a better compromise AFAIU. The count is incremented each time the object is affected to a new pointer (creation or affectation proper), decreased automatically at the exit of the procedure where the pointer is declared, and the object is freed when the count is zero. The size overhead is a word to store the count, the time overhead is the time to increment/decrement the count at affectation or exit of the procedure and check for zero.
Is one of the many object models of gpc doing this automatically ?
Maurice