Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to release and assign an object
Message
From
13/09/2006 17:55:45
 
 
To
13/09/2006 17:25:08
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01153528
Message ID:
01153537
Views:
16
>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?

You can force a Object release ( not variable/property references )
with a
RELEASE this
or
Parent.RemoveObject
RefObject = CREATEOBJECT("someclass")
RefCopy   = m.RefObject

CLEAR

RELEASE RefObject
? RefCopy
RELEASE RefCopy

? "end"

RefObject = CREATEOBJECT("someclass")
RefCopy   = m.RefObject

* this set to null ALL the object references, and the object is destroyed
RefCopy.Release
? RefCopy
? RefObject
? "end2"

DEFINE CLASS someclass as Custom
	
	PROCEDURE Release
		RELEASE this
		
	PROCEDURE destroy
		? "destroyed"
		
ENDDEFINE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform