flex - How to keep track of objects for garbage collection -


may know proper way keep track of display objects created , hence allow me remove efficiently later, garbage collection. example:

for(i=0; i<100; i++){ var dobj = new myclass(); //a sprite addchild(dobj); } 

from know, flash's garbage collection collect objects without strong references , event listeners attached it.

since var dobj referenced new object created, have "nullify" too, correct?

should create array keep track of objects created in loop such as:

var objectlist:array = new array();      for(i=0; i<100; i++)         {             var dobj = new myclass(); //a sprite             addchild(dobj);             objectlist.push(dobj);         }  //remove children each (var key in objectlist) {      removechild(key myclass); } 

does allow gc collect on sweep?

var dobj local variable, after functions, reference gone. @ point, reference fact item on display list (ie, it's being displayed). no work needed garbage collected, need removechild() it. of course there other things elsewhere referencing it, such event listeners, etc.

your second code example should work, long remember no remove them display list, remove them array. or use dictionary weak references, wouldn't need remove them dictionary.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -