Click to See Complete Forum and Search --> : Object chaining


eric33
October 4th, 1999, 06:52 AM
How could i delete an object from memory when the object has been created with New keyword.


Dim obj1 as MyClass
set obj1=new MyClass
' How to delete obj1 from memory ???




If i affect Nothing to obj1 will be the object removed from memory (like a Java garbage collector ) ?

thanx

Lothar Haensler
October 4th, 1999, 07:01 AM
Set obj1 = Nothing
removes the object from memory (under normal circumstances)

eric33
October 4th, 1999, 07:51 AM
So if i understand and i have several object variables that point to the same object i must free all variables

ie :

Dim obj1,obj2,obj3 as myclass

set obj1=new myclass
set obj2=obj1
set obj3=obj1

' now obj1,obj2 and obj3 point to the same memory object

set obj1=nothing
set obj2=nothing
' ONLY the last next line frees the object ????
set obj3=nothing

Lothar Haensler
October 4th, 1999, 08:21 AM
if you want to find out the truth, write a Class_Terminate method ("desctructor") in myclass and check when that method is called. That will tell you the truth about object destruction.