i've looked through few pages of similar inquiries, implemented of suggestions, can't seem find that's worked far. i'm not overlooking glaringly obvious.
right, i'm using aforge.net capture image. provides event, triggered each new frame received, in code looks this:
private void videosourceplayer_newframe(object sender, ref bitmap image) { framesrecieved++; try { if (!stopcapturing) { if (picturebox1.image != null) { picturebox1.image.dispose(); } picturebox1.image = image.clone(new rectangle(0, 0, image.width, image.height), image.pixelformat); } } catch { } { gc.collect(); } }
memory usage stable long window remains stationary, grab window form , start moving about, memory usage keeps going up. reason i've been led believe might related picturebox, because turn "stopcapturing" bool true, memory stops rising, if i'm moving window around screen. "stopcapturing" not used else, , event continues triggering normal, difference image being displayed in picturebox. i'm @ loss cause, appreciated.
ps: not sure if it's related, workstation has 2 screens.
bitmap.clone()
shallow copy, actual bytes still owned caller, potentially cause kind of troubles. need deep copy.
for example, aforge way:
bitmap bmp = aforge.imaging.image.clone(image);
or gdi+ way (could use lockbits, etc. better perfs):
bitmap bmp = new bitmap(image.width, image.height, image.pixelformat); graphics g = graphics.fromimage(bmp); g.drawimageunscaled(image, point.empty);
Comments
Post a Comment