I have an image control that displays a large jpg file and takes around 50mb of memory. How do I dispose of this control when it is no longer needed? I tried removing it from the parent container, setting it to null and chaning its Source property to null, but the memory usage still stays the same... Any suggestions will be highly appreciated!
I think this is an edge case problem with Silverlight due to the reliance on garbage collection. Unfortunately if you are instantiating a lot of objects (and I do mean a lot) then you will get performance degredation (even if you free everything up properly and/or Dispose() of everything) because the GC just doesn't keep up and we don't have the resources to throw around like we do in a "normal" application.
Are you getting an issue, or just memory watching?
I have finally found the answer to my question. The problem was in a memory leak bug in Silverlight. I found the workaround for this problem here: http://blogs.msdn.com/silverlight_sdk/pages/silverlight-bugs-and-workarounds.aspx
Memory Leak when you Dynamically add and remove Images
Workaround: When dynamically adding or removing BitmapImages from an application (a.k.a. adding/removing from the tree), you should set Image.Source = null before removing the Image element from the tree. This will make the BitmapImage eligible for garbage collection. Bug Status: Active bug. *
Thanks everyone for the suggestions!