Thursday, May 15, 2008

Fixing itemRenderer memory leak in AdvancedDataGrid on columns change

Please read the discussion about memory leak here.

I think I found the workaround for this issue. We need to override the set columns method in a extended ADG class and add the code to free the dictionary holding on to the itemRenderers. Here is the code.

<?xml version="1.0" encoding="utf-8"?>
<mx:AdvancedDataGrid xmlns:mx="">
   override public function set columns(value:Array):void
    super.columns = value;
    itemRendererToFactoryMap = new Dictionary(false);


ejbelair said...

good to know. will this be fixed in the next version/hotfix?

Sreenivas said...

Yes! I have no doubts.

Rahul Mainkar said...

Hi Sreenivas,
I have been following your blog for quite some time now.. and kudos to you for your good work.
I have a doubt though.. I thought it would be good to ask it is...

In our project we have a requirement to create custom components and
distribute them to fellow team members.
So as we know we need to create a SWC file for all the custom
components which is fairly simple using flex builder.
However, I want that these custom components must be listed in a
separate category inside flex builders component view instead of
listing all of them under 'custom' category.


When I searched a bit I found that a design.xml or a manifest file is
needed in which we can put together all the properties and categories
of custom components.
Unfortunately I am not able to figure out how to make this work.

I also heard that you need a design.xml file to be put into the FlexLibrary Project to achieve this. Do you have any thoughts on this?


Sreenivas said...

One can create a design.xml file and include it the Flex Library project. In the Project Properties dialog go to the Assets tab in Flex Library Build Path option.

Check the check box againest design.xml file.

On building the swc file you can open it as a zip file and make sure that design.xml is indeed included in the SWC file.

Rahul Mainkar said...

Thanks much

Maik said...

How can we retrieve updates of the datavisualization.swc (which comes with Flex Builder 3)? Are the updates downloadable somewhere?


Sreenivas said...

As far as I know there are no updates available anywhere.

Rohit said...

Hi Sreenivas,

I am struggling with memory leak problem in Advanced Data grid(ADG) for quite some time. In my UI I have got two screens one having a ADG and other having some comboboxes. When I bring switch to the screen containing the ADG, the ADG gets filled with data coming from a web service. Now once I go back to the screen containing comboboxes I need to release the memory held by ADG. This is not happening. Can you help me in this regard ?

Sreenivas said...

I don't know why there is so much concern about memory but anyway...the easiest solution to your problem would be remove the ADG from the container and add it again (+ its initializations) when user switches to the tab. However you have face the loading time of ADG everytime.


how can i see memory leaking in ADG using profiler. Where exactly it is happening?

Sreenivas said...

You can use the profiler on the application which uses ADG. Take memory snapshots at different intervals. Open the memory snapshot and click on the filters button in the tool bar. Remove mx.*.* option. Now in the view you would see how many itemRenderers are being used by ADG. If the numbers are many more than expected you are looking at a memory leak !