I had a similar problem with lists. I found out that the itemRenderer
does not release its reference to the data member. While digging into
the code, I've found out that Adobe has access to the list through the
mx_internal namespace. So, I cooked up a small helper function to
release the itemRenderer. Try to adapt it to the grid.
 
<BEGIN CODE>
import mx.core.mx_internal;

use namespace mx_internal;

/**
* Helper function that cleans up a list's item renderers.
* 
* <P>The item renderers contain a data member that holds a reference to
the data the list was
* trying to display. The list doesn't clean up the item renderers data
member when the list provider is set
* to null. So, this reference prevents elements from being garbage
collected and needs to be manually cleaned up</P>.
* 
* @param list The list for wich the Item Renderers need to be cleaned
up.
* 
*/
 
public static function cleanItemRenderersData(list:ListBase):void {
 
    var renderers:Array = list.rendererArray; // two dimensional array
    var renderer:IDataRenderer = null;
    for (var row:int = 0 ; row < renderers.length ; row++) {
        for (var col:int = 0 ; col < renderers[row].length ; col ++) {
            renderer = renderers[row][col] as IDataRenderer;
            renderer.data = null;
        }
    }
}

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of lmurphy
Sent: Monday, December 01, 2008 8:39 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: objects bound to datagrid not gc'd when
dataprovider set to null



Could anyone point me in the right direction?

I've removed -

* data binding references
* remote object call references - clearResult

However, after setting the dataprovider for my grid to null - the grid
shows no items, in the debugger the dataprovider has a length of 0 -
there are still references to the objects.

All of the references seem to be coming from datagriditemrenderers (I
do not use any special item renderer, simply the default). The
reference list/tree is large with and incomprehensible to me - but
they all seem to be coming from classes I don't control.

Any thoughts?



 

Reply via email to