我的程序也发现一个这样的问题,
http://topic.csdn.net/u/20110331/00/9DD6C6E8-6079-4862-851F-1263E9A5E5FB.html搜索了下,很多相关的问题,居然没找到解决方法.相似的代码如下,调用后图片不释放.    static class AppHelper
    {
        public static BitmapImage GetBitmapImage(string path)
        {
            BitmapImage bitmap = new BitmapImage();
            bitmap.BeginInit();
            bitmap.StreamSource = new MemoryStream(File.ReadAllBytes(path));
            bitmap.EndInit();
            bitmap.Freeze();
            return bitmap;
        }
    }

解决方案 »

  1.   

    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. *
    --------------------------------------------------------------------------------
    http://blogs.msdn.com/b/silverlight_sdk/archive/2008/10/28/silverlight-bugs-and-workarounds.aspx
      

  2.   

    没有调用dispose?GC.collection?之类的方法试试
      

  3.   

    还有这个
    http://social.msdn.microsoft.com/Forums/en-US/windowswic/thread/46bab672-c65c-4194-96ba-03f3cfc32fa4
      

  4.   

    我提交了一个BUG.如果大家有这个问题.也顶一下吧.https://connect.microsoft.com/WPF/feedback/details/680742/bitmapimage-does-not-release-memory-leak-in-wpf4