This project is read-only.

memory leaks in chartplotter how to

Feb 12, 2013 at 4:52 PM
Edited Feb 12, 2013 at 5:08 PM
Halo,
I have a very important question related with releasing memory by D3 ( wpf, not nightly).
I am playing around with ants profiler. Have a memory leaks about 300 kB every hide show of window which is using D3.
to release resources i am using those lines:
this.dynDisp.Children.RemoveAll(typeof(RectangleHighlight));
this.dynDisp.Children.RemoveAll(typeof(LineGraph));
this.dynDisp.Children.RemoveAll(typeof(LineAndMarker<MarkerPointsGraph>));
this.dynDisp.Children.RemoveAll(typeof(ViewportAxesRangeRestriction));

also I am removing with:
this.dynDisp.Children.Remove(lm.LineGraph);
this.dynDisp.Children.Remove(lm.MarkerGraph);

where 'lm' is a linemarkergraph collected during adding to the graph.
I am also clearing another data I am using, removing adding event handlers etc and finally i reached 300kb which is very hard for me to overcome...
What is interesting - when I use this line below:
this.dynDisp.Children.RemoveAll(typeof(object));
Im left with 100 kB of leak every hide and show ! But then nothing is on the display after next show ... this is really D3 specific issue!

Could somebody help me in this matter - will appreciate

Edit: without D3 chartplotter ( all logic the same ) I am gaining 6 kB per hide show !!!

Best
Jakub
Poland
Feb 15, 2013 at 8:51 AM
Edited Feb 15, 2013 at 8:54 AM
Hi

If you add some events like "lineGraph.DataChanged", "ViewPortPropertyChaged", "MouseDown/Up" events , you should remove those events also.
Also check the this.dynDisp.Children.Count before and after removing the linegraphs and markers.
If you are adding injected, check those are removed are not.
Remove vertical/Horizontal axes also if added some

Regards
Ravi.Battula