0 Replies Latest reply on Jun 23, 2006 11:53 AM by audio:theory

    How does the Garbage Collector handle reference-free objects?

    audio:theory
      Hi,
      I am interested to know how the GC handle's objects created without a reference.

      The reason this has become of interest to me is that I have created a "Title" class. The Title class animates each letter of Title.text to appear in a cloud of smoke.
      The smoke is a simple particle system class, when a particle dies it removes it's associated MovieClip so that eventually all MovieClip's have been destroyed.

      Now in the Title class for each letter I do the following (psuedo-code):

      for( Title.text.length) {
      CurrentLetter.twAlpha = new Tween( blah, blah, blah); // object created with a reference
      new Smoke( CurrentLetter.x, CurrentLetter.y); // object created without a reference
      }

      Although this is technique is not one I would ever have thought of in a language that doesn't use a garbage collector it is mentioned in the Tween documentation and my class works as intended.

      The thing is although it works, it always bothers me when I don't know precisely why it works!

      If it's working due to the short life span of the class in question and thus simply missing the GC's window then this could be problematic. If at some point it is still alive when the GC is called then my class could be prematurely deleted.

      Maybe a class which has a reference to an "alive" MovieClip is immune from GC?

      I Hope someone can shed some light on this topic as the GC is something that is thinly documented to say the least!


      :theory

      p.s. first post!