我是C#的新手.我必须在工作线程中重复刷新GUI图片框.从使用GetImage方法轮询驱动程序的摄像机获取图像,该方法检索要显示的图像.即使我使用指令"using"分配位图并显式调用GC,内存似乎永远不会被释放.
工作线程是这样的:
while (true)
{
// request image with IR signal values (array of UInt16)
image = axLVCam.GetImage(0);
lut = axLVCam.GetLUT(1);
DrawPicture(image, lut);
//GC.Collect();
}
Run Code Online (Sandbox Code Playgroud)
虽然DrawPicture方法是类似的
public void DrawPicture(object image, object lut)
{
[...]
// We have an image - cast it to proper type
System.UInt16[,] im = image as System.UInt16[,];
float[] lutTempConversion = lut as float[];
int lngWidthIrImage = im.GetLength(0);
int lngHeightIrImage = im.GetLength(1);
using (Bitmap bmp = new Bitmap(lngWidthIrImage, lngHeightIrImage)) {
[...many operation on bitmap pixel...]
// Bitmap …Run Code Online (Sandbox Code Playgroud)