0 Replies Latest reply on Jan 25, 2008 12:09 PM by Quatrol

    Strange Memory Behavior With Accordion

      Hello everyone,

      I have been having a strange case of memory leak in my application, and i tracked it down to the accordion component. Not quite understanding why it leaked, i made a real basic application to test the component, and what i've is quite disturbing.

      My test application has 2 buttons, one to add an accordion to the canvas, and the other to remove it. While the accordion gets collected if i only add it and then remove it, if i ever navigate the accordion, it gets stuck into memory, but only until i add a new one. Anyone understand why it does that ? (also seen that same behaviour with popups)

      Here's my test application's code :


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="vertical" horizontalAlign="center" verticalAlign="middle">
      <mx:Script>
      <![CDATA[
      [Bindable]
      private var bool: Boolean = false;

      private function button1Handler():void
      {
      if (!bool)
      {
      bool = !bool;
      var dummy: AccordionTest = new AccordionTest();
      dummy.name = "dummy";

      box.addChild(dummy);
      }

      }

      private function button2Handler():void
      {
      if (bool)
      {
      bool = !bool;
      var dummy: AccordionTest = box.getChildByName("dummy") as AccordionTest;
      box.removeChild(dummy);
      }
      }

      ]]>
      </mx:Script>

      <mx:HBox id="MyBox">
      <mx:Button id="myButton1" label="add" click="button1Handler()" enabled="{!bool}"/>
      <mx:Button id="myButton2" label="remove" click="button2Handler()" enabled="{bool}"/>
      </mx:HBox>
      <mx:HBox id="box"/>
      </mx:Application>


      And here's the accordion component's code:


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="400" height="300">
      <mx:HBox>
      <mx:Accordion>
      <mx:Canvas label="box1" width="100" height="100" backgroundColor="red"/>
      <mx:Canvas label="box2" width="100" height="100" backgroundColor="green"/>
      <mx:Canvas label="box3" width="100" height="100" backgroundColor="blue"/>
      </mx:Accordion>
      </mx:HBox>
      </mx:Canvas>



      Thanks,
      Q