4 Replies Latest reply on Jun 26, 2010 10:37 AM by rashmin.d

    Unable to get some objects to Garbage Collected

    WeeJavaDude

      We are starting to do some memory analysis and I am running into an issue where my objects don't appear to be GC'ed.   I have used the profiler and have gotten the objects down to where there appears to be no references left.   Here is some info about the objects in hopes it will provide some clues as to why perhaps my objects are not being reclaimed.   Given I am new to Flex memory profiling I am not even sure if they should be.

       

      1)  The objects are created as local variables in a function and passed into another object that holds a reference.

      2)  I have a function that gets called that cleans up the objects by calling dispose on the parent objects,  nulling all references to the objects,  and clears out any arrays that contained the objects..

      3)  The Object References window shows no references (See below object ID 426971)

      memleak.png

       

      So my questions are.

       

      1) The main object where these objects are being created lives for the life of the application.   Should I expect that objects created within the main object that have no references to hang around until the application gets into a memory constraint situation and then GC these objects?

       

      2)  For Objects that don't appear to have any references to them,  is there something else I need to be looking at to assure they get freed when GC comes around.

       

      Thanks in advance for any suggestions the community my have.

        • 1. Re: Unable to get some objects to Garbage Collected
          rashmin.d

          hi...WeeJavaDude

           

          on the basis of your mess. For take care of GC of your Objects...

          you have to consider 1) all reference should null to that Objects..

               2) U should disp. them by calling from parent.

               3) Most important is u have to remove all event Listener from that Object... becoz of event life cycle if event listener is still there then it will live untill appli. end...

           

          other points u know.... so....i think this will help u......

          • 2. Re: Unable to get some objects to Garbage Collected
            Flex harUI Adobe Employee

            In theory, the Object References view should never show an object with no

            back references.  There is a chance that the GC did not get around to that

            object, but hitting the GC button in the profiler a couple of times

            (assuming the app is idle) should guarantee that the mark and sweep took a

            look at the object.

             

            If the object is still around after doing that, it might be that the object

            is being cached by the Flash Player.  There are some issues with AIR apps

            where objects that listen to AIR object events don't get their back

            references shown.  Study the objects in question and make sure that event

            listeners are being removed.

            1 person found this helpful
            • 3. Re: Unable to get some objects to Garbage Collected
              WeeJavaDude Level 1

              Yes I did press the GC button a number of times and I have done a complete review of all the events listeners that we assigned to this object and there is only one which is removed before the object is nulled out.   Wouldn't i still see a reference if there was a dangling event listener.   To add a wrinkle to my issue,  there is some interaction with this object and a third party library so I don't have full visability into all interactions to this object and since there is no references to this object I have no path to follow since I have cleaned up all references.   

              • 4. Re: Unable to get some objects to Garbage Collected
                rashmin.d Level 1

                hi......WeeJavaDude  , 

                 

                whatever i suggested, same thing suggested by Flex harUI n he add some imp. points into it... thanks..... Flex harUI.....

                 

                Coming to your probl. u tried every thing, Try this last thing, remove the object from the parent by remove child and assign null to parent properties n assign null to child properties of parent object... May be this will help u... but.... as per Flex harUI if AIR stores object in cache then its diff. prob.... May your object refe. using by some shared lib or class so it is storing that in cache or it live through out the life of app.

                 

                And in the last reply you written that don't have full visability into all interactions to this object becoz you r using third party lib. So, May be this will help u...

                 

                Thanks for reply....