3 Replies Latest reply on Jun 16, 2011 12:41 AM by ognz

    DataGrid Garbage Collection problem


      I'm quite confused about the DataGrid component's garbage collection. I've made a simple test code which adds a datagrid to the display list. If I remove the component from its parent without clicking any item, the element is collected correctly. However, if I click an item, the datagrid is no longer removed. Otherwise, if I use the keyborad to navigate through the items, the component is removed.
      The profiler doesn't display any inbound reference to the datagrid. So, what's the problem? Is Flex retaining any reference when I use the mouse?
      Thanks in advance.

        • 1. Re: DataGrid Garbage Collection problem
          Flex harUI Adobe Employee

          Post the test case.

          • 2. Re: DataGrid Garbage Collection problem
            ognz Level 1


            here it goes:


            the main application:

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
                           import com.adur.nodes.Child;          
                           private var _child:Child;
                           private function onLinkClickHandler(event:MouseEvent) : void {                    
                                _linkButton.enabled      = false;
                                _unlinkButton.enabled      = true;
                                _child = new Child();
                           private function onUnlinkClickHandler(event:MouseEvent) : void {               
                                _linkButton.enabled      = true;
                                _unlinkButton.enabled      = false;
                                _child = null;          
                 <mx:VBox width="100%" height="100%">
                      <mx:HBox width="100%" height="30">
                           <mx:Button id="_linkButton" width="100" label="Link" click="onLinkClickHandler(event)" />
                           <mx:Button id="_unlinkButton" width="100" label="Unlink" enabled="false" click="onUnlinkClickHandler(event)" />
                      <mx:Box     id="_content" width="100%" height="100%" />


            the Child class:

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" >
                 <mx:ArrayCollection id="collection">
                           <mx:Object label="Option1" score="85" />
                 <mx:List dataProvider="{collection}" />


            thanks harUI.

            • 3. Re: DataGrid Garbage Collection problem
              ognz Level 1

              Ok, solved.
              The problem with the DataGrid’s garbage collection dissapears when a Flex SDK update is performed. We have been using the version 3.2 for a long time limited by development requirements of the program. Tests with the version 3.6 have been successful. So, it's time to upgrade. Thanks.