habox15 / twaindotnet

Automatically exported from code.google.com/p/twaindotnet
0 stars 0 forks source link

Memory Leak in the Wpf Test App #28

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The statment(Window1.xaml.cs): 
image1.Source = 
Imaging.CreateBitmapSourceFromHBitmap(System.Drawing.Bitmap(args.Image).GetHbitm
ap(), ...) 

Creates a HBitmap in memory that is never freed.
You need to use DeleteObject to free it:
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);

Original issue reported on code.google.com by vidarlun...@gmail.com on 10 Feb 2011 at 2:48

GoogleCodeExporter commented 8 years ago
Hi,

If you submit a patch I'll look at it and apply it to trunk.

Cheers,

Luke

Original comment by luke.qui...@gmail.com on 10 Mar 2011 at 1:58

GoogleCodeExporter commented 8 years ago
I was having issues accessing your source control from work but thought I'd 
just send along the modified files with the changes suggested by vidarlun - we 
ran into this memory leak (~32 MB leaked per scan in our case) and this indeed 
seems to have fixed it.

Original comment by jesse.go...@gmail.com on 4 May 2012 at 4:40

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the changes. I've pushed them into trunk here:

http://code.google.com/p/twaindotnet/source/detail?r=2ec78e5cf95ebc35a25702ab03e
a5c46c80f0199

Original comment by luke.qui...@gmail.com on 20 May 2012 at 11:35