0 Replies Latest reply on May 22, 2007 8:57 PM by codetale

    pointer and GC

    codetale
      i am using the flash.utils.Dictionary objectClass
      and i have some doubt about how GC work with the Dictionary

      as i know, GC only collect/free the memory if there no more reference to the object

      var objA:Object = new Object()
      // the new keywork will allocate the [Object] in memory and objA are the pointer which point to [Object] memory address
      // is that right ?(if i was wrong pls correct me)
      var objB:Object = objA;
      // ok, now i create again a pointer to the [Object]
      delete objA
      // the GC not collect the [Object] because there still have pointer pointing to it (objB)
      delete objB
      // now the GC will collect the [Object] at next circle because there no more reference.



      but the problem is, Dictionary can use object as its key
      var dict:Dictionary = new Dictionary()
      var objA:Object = new Object()
      var objB:Object = new Object()

      dict[objA] = true
      dict[objB] = true

      delete objA
      delete objB

      will GC collect the objA, objB?
      because i never do the following:
      delete dict[objA]
      delete dict[objB]

      but direct
      delete dict // or dict = null