Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to release and assign an object
Message
 
 
To
14/09/2006 10:52:41
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01153528
Message ID:
01153748
Views:
21
Wei,

In a single linked list, if you want the entire list to destruct when the head is eliminated:
oHead = .null.
Then using the Destroy() method is enough.

If you have a more complicated doubly (or more) linked list then you usually have to have some custom code to make sure everything cleans up ok. I use a custom name for this sort of method rather than using the Release() method.

VFP objects all have an internal reference counter, everytime a reference is stored to a memvar or property the counter is incremented, everytime the reference is cleared the counter decrements, when it decrements to 0 the object destructs, essentially right then, there is not a separate garbage collector thread running on its own.

FWIW (I don't know your familiarity level with VFP), I'll mention that you may be able to use the Objects() collection of a container rather than going through a effort of maintaining your own a linked list of objects.

>Hi, David, Thanks for the response. I have next=.NULL. as you said. I just wonder whether it would be sure to get the memory released. All my classes are derived from custom control and they have property linking to other. Is it better or necessary to define a release method to release and clean up, as comparing to remove the references and letting garbage collector to do the job? What is the best way to deal with create and release object?
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