2011-02-08 28 views
2

我正在使用Aforge.Net從網絡攝像頭獲取單幀並通過圖像控制顯示它。每當用戶點擊按鈕時,我正嘗試用網絡攝像頭獲取的新圖像更新圖像控件。一切似乎工作正常,但內存使用不斷上升。我不知道如何解決這個問題,在我的應用程序。圖像控制中的內存泄漏wpf

Bitmap _image = aforge.Test(); 
WebCamVideo.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
    _image.GetHbitmap() 
    , IntPtr.Zero 
    , System.Windows.Int32Rect.Empty 
    , BitmapSizeOptions.FromWidthAndHeight(
     _image.Width 
     , _image.Height) 
); 
WebCamVideo.Source.Freeze(); 
_image.Dispose(); 

回答