I have a test program. There are 2 buttons. One button is used for adding 2000 graphics, the second one is used for
clear all graphics.
By monitoring the memory, I found the memory used is keeping increasing when I click "Add", "Clear", "Add", "Clear", .....
Is there a way to solve the memeory leak?
Thanks
if ((sender as Button).Name.Equals("btnClear"))
{
(dpMap.Layers["SelectionHighLightLayer"] as GraphicsLayer).Graphics.Clear();
(dpMap.Layers["SelectionHighLightLayer"] as GraphicsLayer).ClearGraphics();
GC.Collect();
GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
}
else
{
ESRI.ArcGIS.Client.Geometry.Geometry geom = new MapPoint(-3105,5650533) ;
for (int i = 0; i < 2000; i++)
{
(dpMap.Layers["SelectionHighLightLayer"] as GraphicsLayer).Graphics.Add(new Graphic()
{
Geometry = geom,
Symbol = ResultsMarkerSymbol
});
}
}