I’m facing some problems with my silverlight application.
My application looks like an image manager. You can open some images, edit, view, etc.
My problem is that when you add some images and after remove these images, the memory doesn’t return to the same amount used before you add these images. If you repeat these operations (add images and after remove these images), the memory doesn’t stop going up.
Why it’s happen?
I create a new silverlight 5 project for recreate this scenario, test some codes and try find what is happening.
In the new project I have a StackPanel and 3 buttons with these actions:
1- Add 1000 buttons in a StackPanel;
2- Remove all children of StackPanel;
3- Call GC.Collect;
I call the same actions repeatedly: add(1), remove(2), call GC(3)
After I repeated several times the same action (add and remove). I observed the same result of my first application, the memory doesn’t stop going up. Even after I call the GC.Collect the memory is not freed. I don’t now what’s happen. Is it a possible memory leak of silverlight?
Is your PC ‘tablety’?
Silverlight automation kicks in if you have an automation client running on your computer. The most common being:
This makes silverlight a complete mess and causes a number of bugs, and almost-always makes everything leak like crazy.
I disabled automation by setting this parameter in my html:
You can read more here: Silverlight + MVVM + Bindings = Memory leaks?