First I'm sorry that I'm asking this totally ambiguous question. I have encountered a very confusing problem that I don't know how to solve.
It is not even possible to write some sample code here because it is related to my application as a whole. I'll try to explain this though.
I have two Canvas objects:
- Canvas A
- Canvas B
that I'm using in my application to draw Line objects on them. I also have two Button objects that I use to switch between Canvas A and Canvas B.
Now When I switch to Canvas A I start drawing on Canvas A and I clear all of the children in Canvas B and when I switch to Canvas B I start drawing on Canvas B and I clear the children of Canvas A.
After some time going back and forth between these two canvases, my program becomes very slow. I tried Ant Profiler and took memory snapshots. Once when I start the program and once when I feel that it has become slow.
The difference in size is around 135 KB. Is this a memory leak? 135 KB doesn't seem to be that much? What else can cause the problem?
Do the Line objects that I draw each time when I switch reside and aggregate in the memory despite the fact that I clear the children of the canvas? Since the number of the Line objects are high they may cause a problem if they reside and aggregate each time. How can I make sure?
Any suggestions are truly appreciated.
Update:
when I switch to CanvasB this is the code I use to clean the CanvasA:
CanvasA.Children.Clear();
I'm using DrawingVisual to draw the lines.