PDA

View Full Version : Any good post/articles on garbage collection for Display Objects?



zhangxiaorui
February 27th, 2009, 05:22 AM
I've been in a trouble with "removeChild" for a while. I know there must be some great discussion around but just could not find some nice posts in details. Anyone give me some tips even links? I wanna know as detailed as possible.

Thanks in advance!

theCodeBot
February 27th, 2009, 07:40 AM
I'm not sure what you're looking to find out here.

As far as garbage collection goes on DisplayObjects, it is automatic.

If you have references a, b, and c, to object o, which is on the display list, then in order to make the garbage collector get rid of it, you must first remove it from the display list, then you must get rid of a, b, and c, then you must make o null. After o is null, not on the display list, and there are no references to it, the garbage collector deems it useless, and throws it out.

(If, of course, o is actually a hard-coded variable, then it won't go away, just stay as a null object. Any dynmaically definied variables, such as those created only inside a function, will die completely.)

Avdi
February 27th, 2009, 11:25 AM
automatic garbage collection has some delays and in some cases might cause problems
you can call gc service manually by

System.gc();

this might help you
http://www.nbilyk.com/flash-garbage-collection