Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to release and assign an object
Message
From
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:
01153713
Views:
17
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?

>Wei,
>
>If you are implementing a single linked list, you should make sure that the Destroy() method sets the .Next object reference to .null. just from the standpoint of having well behaved classes that clean themselves up properly.
>
>
>define class my_object
>Next = .null. && next list object
>
>function Destroy
>this.Next = .null.
>return dodefault()
>enddefine
>
>
>>I wonder whether I could get some feedback on the following problems.
>>
>>I have a few lines of codes to create an object, use it, and release it later.
>>
>>o1 = createobject("my_object")
>>......
>>
>>oCurrent = o1
>>... do something with oCurrent ....
>>
>>o1.next = createobject("my_object")
>>oCurrent = o1.next
>>... do somethig with oCurrent ....
>>
>>&& now I try to release to objects
>>release oCurrent
>>release o1
>>
>>My questions are:
>>1. does oCurrent = o1.next copy the object or just the reference of the object?
>>
>>2. does release oCurrent release the memory acquired in 2nd createobject?
>>
>>3. does release o1 release the memory for both createobject(...) even without the release oCurrent?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform