Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top