There should be no need to remove the renderers unless something outside of
the DG is referencing the renderers. As long as the DG references the
renderers and the renderers reference the DG, the whole set will be garbage
collected once there are no other references to the DG and renderers.
Yes, I agree with that once the DataGrid is no longer referenced by other components, they will be GC together.
But my situation is that the display is quite complicate and I cannot make the DataGrid being NOT referenced by other components.
I am comfortable with the DataGrid itself leaving in the memory, as I can see from Profiler it is not large enough, but not for renderers, there are many instances created and each is very large so that's why I want to find a solution to manually de-reference from the grid.
Is it possible from the code level to achieve this?
Thanks in advance.
It would be a good practice to find a way to dereference the DG when no
longer needed. Your code will be easier to maintain if you code up ways to
Getting the DG to free its internal renderers may be tricky. Setting the
dataProvider to null and or itemRenderer to null might help.
Thank you harUI, yes, I agree with that best practice should be dereference the DG when no longer needed.
however, the DG is an item renderer in another grid (let's day dg1).
and what the best way to dereference dg1? I tried setting dg1=null but no luck.
I will try your solution by setting the dataProvider to null and itemRenderer to null.
Thanks for your help.
You will have to use the profiler to find all the references.
I can see all the references are the objects inside this grid (for example the itemrenderer in one column).. it looks weird.
If there is a DG which has one column as itemrenderer. and from the profiler,
I can see the DG is referenced by the itemrenderer and itemrenderer is referenced by DG also. there is a loop.
how the Flex VM handle GC in this situation?
Flex 4 profiler does not provide a way to see object references. Flex 3 profiler might (I would have to check)