Вопрос

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