Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
How to release xamDataGrid memory ?
posted

Hi,

I am creating a very complex XamDataGrid using code. Once loaded, the grid consumes around 400mb of RAM.

Some actions in my application require removing the old XamDataGrid and adding a new one.

The problem is when i remove the old XamDataGrid , its memory is still not freed. Then addition of new grid consumes another 400mb ram. Multiple iterations of this action ultimately results in SystemOutOfMemory exception.

Here is how i am removing XamDataGrid.

SelectedGrid is the parent.

SelectedGrid.Children.Remove((XamDataGrid)SelectedGrid.Children.Cast<UIElement>().First(e1 => Grid.GetRow(e1) == 4 && Grid.GetColumn(e1) == 1));
SelectedGrid.UpdateLayout();

I even tried forcefully calling the GC. But it still does not frees up the memory.