1 Reply Latest reply on Mar 14, 2008 5:44 PM by Gregory Lafrance

    application memory

    ljonny18 Level 1

      I was wondering if someone could help me out...

      I have an application where containing a veiwstack. Each tab / section of the viewstack contains different components (.SWC).

      depending on the application status at any particular time, the components are added when a particular tab is selected and removed when another tab is selected etc etc....

      I have a memory issue with my application and I believe that it is to do with the adding and removing of children (components) to and from the application.

      I have read up about adding and removing childeren form the display of an application using the addChild() and removeChild() methods.
      I am aware (correct me if I am wrong) that when removing a child using the removeChild() method this simply removes the child from the application display and not from the application memory until the garbage collection is ran. I am also aware that the child will not be removed by the garbage unless all the references to that child have also been removed.

      q1, when the gargabage collection is ran - will it remove the whole child from memory???

      q2, how reliable is the garbage collection, and how often does it run???

      q3, if a child is removed and then added again beofre the garbage collection has taken place - will the complete child be added again on top of the existing child thus increasing memory... or will it use the references to the existing child (that is waiting to be removed)???
      also... if the same child is being added but with a different DataProvider or other relevant factors... is this still the case???

      any help on this is geatly appreciated.


      PS - I should maybe also note that this application is being ran as an AIR app.

        • 1. Re: application memory
          Gregory Lafrance Level 6
          Don't forget you must call removeEventListener in a manner corresponding to each time addEventListener was called on each object, otherwise a reference will remain and the object will not be garbage collected. And if you called addEventListener twice, once with useCapture set to true, and once with useCapture set to false, so the event participates in the capture and bubble phases, you need to call removeEventListener twice, once with useCapture set to true, and once with useCapture set to false.