6 Replies Latest reply on May 25, 2009 8:14 AM by *Prashant Shelke*

    FleX data grid memory leak issue

    sai..

      Guys
      I am running in to a major memory leak issue and would appreciate it if someone can help -
      I use a data grid and set the data provider to an arraycollection. Now i update the arraycollection (several (like 20 - 50) times per second) and saw that this would refresh the whole data grid and spike up the CPU. So I decided to separate the data source update from the data grid update (UI update) and to suppress the datasource automatically updating the data grid, i decided to set disableautoupdate but to my dismay this has create a memory leak situation as apparently Adobe doesn’t disable it but rather queues the change events …

      so to solve i embarked on a series of solutions which all doesn’t solve it or creates its own issues -
      1. Create a new class extending datagrid and overwrote the
      override public function set dataProvider(value:Object):void
      {
      super.dataProvider = value;
      //super.removeEventListener(CollectionEvent.COLLECTION_CHANGE, collectionChangeHandler);
      collection.removeEventListener(CollectionEvent.COLLECTION_CHANGE, collectionChangeHandler);
      }

      2. i set disableautopupdate and set up a timer to do enableautoupdate() and disableautoupdate()
      - this works but everytime the timer kicks in, i can see the CPU spike

      3. Overwrote
      override protected function collectionChangeHandler(event:Event):void{
      return;
      }
      this works for the most part but on load it doesn’t display data till i resize the panel …

      Now, let’s not focus on why i need to update 20 - 50 times a second, it’s a trading application and quotes stream in that fast. Let’s assume that’s the right problem to solve …

      Any help anyone can provide is extremely appreciated … i am posting here since it seems like you guys are interested in memory leaks …

        • 1. Re: FleX data grid memory leak issue
          Michael Borbor Level 4

          Hi there could you post your project test case? I assume you're ussing an ArrayCollection as the dataProvider, tests have been made and when dealing with very large amount of data the inner workings of the AC can perform up to 20 times worse than an Array due to binding mechanisms.

          • 2. Re: FleX data grid memory leak issue
            sai.. Level 1

            I have a data grid getting streaming quote data (for a trading

            application we are building in Flex). I get at least an update per

            symbol and the user can typically have anywhere from 20 symbols to 50

            symbols on the grid -

             

            so my test case, is i have 30 symbols in the data grid and each of

            them get an update / second (4 or 5 columns in the grid get updated)

            - so i find the index of the symbol who row needs to get updated and

            update those fields (also update the corresponding data source to

            handle other scenarios) ...

             

            let me know if you need any other info ?

             

            2009/5/10 Michael Borbor <forums@adobe.com>:

            Hi there could you post your project test case? I assume you're ussing an ArrayCollection as the dataProvider, tests have been made and when dealing with very large amount of data the inner workings of the AC can perform up to 20 times worse than an Array due to binding mechanisms.

            >

            • 3. Re: FleX data grid memory leak issue
              Michael Borbor Level 4

              Yes a minimal test case, like the one that you publish on the Flex JIRA will be great. I don't know if you have a chance to see the Trader Application in LiveCycle DS it does kinda the same stuff that your app does, but it performs well so I guess the issue must be somewhere else. How do you update the data? Do your app do some sort of processing with the data once it arrives?

              1 person found this helpful
              • 4. Re: FleX data grid memory leak issue
                sai.. Level 1

                Yea, i parse the response to create some processed data which i send

                in for updates (the parsing is done on a different thread, runs in its

                own timer) ...

                 

                i am curious how they update the grid .... updating labels and

                everything is fine ... just the darn datagrid ...

                 

                Thanks Michael -

                 

                 

                2009/5/10 Michael Borbor <forums@adobe.com>:

                Yes a minimal test case, like the one that you publish on the Flex JIRA will be great. I don't know if you have a chance to see the Trader Application in LiveCycle DS it does kinda the same stuff that your app does, but it performs well so I guess the issue must be somewhere else. How do you update the data? Do your app do some sort of processing with the data once it arrives?

                >

                • 5. Re: FleX data grid memory leak issue
                  Michael Borbor Level 4

                  You can look the source code, all the magic is done by LCDS that handles the pushing and pulling of data.

                   

                  the parsing is done on a different thread

                  Inside your flex app or in your server?

                  • 6. Re: FleX data grid memory leak issue
                    *Prashant Shelke* Level 4

                    Here is the simple solution I have tried & got major effect.


                    1. Before assigning any new dataProvider you have to call,

                              dataGrid.dataProvider.removeAll();// dont call dataProvider = null it has no effect.

                              System.gc();


                    2. If you are re-building dynamic columns on each time & before setting new columns to dataGrid,

                              dataGrid.columns.splice(0, dataGrid.columns.length);


                    Some time styles & event listeners can be culprit to memory leak(You can try to use Flex memory profiler for the same)

                    Thanks.