문제

My Code is basicly like that:

Collecting frames from webcam on every 100ms in this method.

MutexControl.Image.WaitOne();
image = null; 
image = (Bitmap)eventArgs.Frame.Clone();

Bitmap Myimage = new Bitmap(Form1.image);
MutexControl.Image.ReleaseMutex();

image is My static reference. I use it in other parts of my program. is this make any problem with memory management. Does Garbage Collector collect my trash images?

도움이 되었습니까?

해결책

The System.Drawing.Bitmap class implements IDisposable, so yes, you should be disposing it before reassigning the static field. If you don't dispose it, you may put excessive pressure on the finalizer thread and you will see increased memory usage.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top