Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to deal with object's referencing each other
Message
 
 
To
15/08/2003 06:53:13
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00820420
Message ID:
00820630
Views:
19
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?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform