Hello foxdbs,
But if I have assigned a previously existing object into a property, and I call ReleaseMe() for it, then, maybe, such object shell continue live and it is not good idea assign NULL into its properties.
Why isn't that good? If you assign NULL to such a reference that was given by parameter and stored in a property you are not really destroying the object, if there are other references, as you observed yourself.
On the other hand I'd only set such a property to NULL to clean up everything, in the knowledge that the object to which this NULL set property belongs will not again access this property and/or be released itself soon. And if this is done subsequently, you wouldn't have problems with finally releasing oApp.
That oApp cannot be properly released at the end is a problem. But I think solving it with such a forcing recursive reference killing method is not a good solution. You should find out where and what references remain and where you didn't release something properly.
As a reference is a reference
to another object and you can't easily determine
from where some reference points to THIS, it's hard to do. Well, many classes have an Objects-Array (or rather a collection), but you'd have to recursively search all of these and some classes have Addproperty() but no Objects property, so you may not be able to extract all needed informations and find all references.
A good strategy may be to have mediators, that are objects who know about other objects and how to handle them. Then for example a form calling a child form wouldn't pass THISFORM to the child form, but a reference to a mediator object, which has a reference to THISFORM. Then the childform would talk to the mediator, if it want's to do or know something of or from the parent form and the mediator would talk to the appropriate form. The mediator is mainly decoupling. Forms "log" in and out of such a mediator object, that thereby knows which references are or are not needed anymore, if releasing is allowed or if some depending objects or forms are not finished yet. Think of it as an intelligent reference in both directions. That may also decouple "sister" objects and thereby decouple objects n:m relations.
Bye, Olaf.