Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to deal with object's referencing each other
Message
De
21/08/2003 04:50:46
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00820420
Message ID:
00822113
Vues:
15
Hi David, your first suggestion sounded promising, but didn't seem to work.

Is the Destroy Method fired at all if an object is still being referenced?

Thanks
Kev

>Kev,
>
>If you have references like:
>
>oX <-> oY
>
>meaning that oX and oY have pointers back and forth between them, and it's a class that understands this linking then you can explicitly code for it
>
>
class.Destroy
>this.oRef.oRef = .null. && clear the pointer back to me
>this.oRef = .null. && clear my pointer to him
>
>In some complex multiple linked list structures I've created over time I've maintained a single linked list that runs through all objects, then the code looks something like:
>
>
>oRoot.Release()
>
>*class.Release
>local loObject, lnObjects, loNextObject
>lnObjects = 0
>loObject = this.oAllocationChain
>do while ! isnull( loObject )
>   lnObjects = lnObjects + 1
>   dimension laObjects[lnObjects] && temp array maintaining a ref to each
>   laObjects[lnObjects] = loObject
>   loNextObject = loObject.oAllocationChain
>   loObject.ReleasePointers()
>   loObject = loNextObject
>enddo
>
>laObjects = .null. && remove last ref to each object so they finally destruct
>return
>
>*class.ReleasePointers
>this.oParent = .null.
>this.oChild = .null.
>this.oLeft = .null.
>this.oRight = .null.
>this.oAllocationChain = .null.
>
>
>>How can I safely clear all objects in memory when there are certain objects holding references to each other?
>>
>>Whenever I try it ends up crashing VFP, I understand that VFP's garbage collection cannot cope with this on it's own, and for the record I have code in the Destroy Method(s) which set all references to .NULL., but this doesn't seem to be enough.
>>
>>It's quite a complex situation, so I wouldn't be able to describe in words, only pictures.
>>
>>Any ideas on how to deal with this situation?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform