Hi there kirupians!
So i always wondered about following: how to properly flag a collection of complex objects for garbage collection.
Example:
MyComplexObject - a class with following simple public variables:
myString:String;
myInt:int;
Lets say we have collection of MyComplexObject-s in an array:
var myCOs:Array = [new MyComplexObject(), new MyComplexObject()];
So far so good…
Now lets have this collection inside a class, and this class defines a public dispose() function, that when called from outside, should flag all the objects in the class ready for GC and also considering we have no ref to the instance of the class (parent.classInstance = null), remove it from memory.
Question:
How do we flag the objects within the class ready for GC?
Possible answer:
A)
myCOs = null;
OR
B) do we need to also nullify ref to each complex object within the collection???
for each (var o:MyComplexObject in myCOs)
{
o = null;
}
myCOs = null;
So which is correct? A) or B)? Or am i amiss here completely?
Thanks!
-w