9 Replies Latest reply on Nov 24, 2010 10:52 AM by Flex harUI

    Garbage Collection not working

    RandomReado Level 1

      I have a TitleWindow component that I'm displaying via PopUpManager.addPopUp(). When I close the component, I'm calling the closePopUp Event which sets the object's variable to null, as follows:

       

      // application
      private var myObject:MyObject;
      
      private function openPopUp():void
      {
          myObject = new MyObject();
          myObject.addEventListener('closePopUp', closePopUp);
          PopUpManager.addPopUp(myObject, this, true);
      }
      
      private function closePopUp(e:Event):void
      {
          myObject = null;
      }
      

       

      However in debug mode I can see myObject being set to null, but the memory usage doesn't decrease. When I open the component again, the memory usage remains the same as before.

       

      I would have thought when the myObject variable is set to null, GC recycles the object and frees up memory. Any idea why this is not happening?