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