Memory Leak – Changing ColumnSeries itemRenderer at runtime – FLEXDMV-1882

November 10, 2008

I wanted to post this small fix that I tried out for fixing the memory leak when changing itemRenderers for a flex chart.

The sample files for the bug mentioned in are used to illustrate the fix.

The fix done was, to set the instance cache of the itemRenderer in ColumnSeries to be removed when not being used. Specifically the following needs to be done.

1. Goto this function in which is part of your DMV source at src\mx\charts\series\

override public function styleChanged(styleProp : String) : void

2. For the condition – else if(styleProp == “itemRenderer”)

Have the following code

_instanceCache.discard = true;
_instanceCache.remove = true;
_instanceCache.count = 0;
_instanceCache.remove = false;
_instanceCache.discard = false;

This should take care of removing unwanted instances when the itemRenderer gets changed.

I ran the sample without and with the changes for 1 minute by changing the itemRenderer every 5 seconds. Here is the result of that, i.e. the itemRenderers that needed to get updated at that given time. Notice the number of itemRenderers that existed after the change is far fewer than the one without the change.

With Change

itemRenderer2 : 47
itemRenderer1 : 59

Without Change

itemRenderer2 : 391
itemRenderer1 : 451

This fix is only for ColumnSeries, if you want it for any other series make sure to make similar changes in that file as well.

Let me know if this fixes the memory leak on changing of item renderers as well as some of the real-time flex charting itemRenderer related memory leaks.


5 Responses to “Memory Leak – Changing ColumnSeries itemRenderer at runtime – FLEXDMV-1882”

  1. Eddie Berman Says:

    Thanks Sunil.
    I’m not sure, though, how I can access _instanceCache, since it’s declared as private.


  2. sunban Says:

    Hi Eddie, You cannot change this by overriding the function, you have to modify the source in

  3. Tonihb Says:

    Hey sunban, I thought i was the only person in the world with this problem. I am having a similar issue like this for the linechart. I’m using multi axes, so when i remove a verticalaxis that is not being used, the chart responds appropriately, but the old axisrenderer is still visible in the background. How can I remove that axisrenderer from the chart’s memory. Thanks so much.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: