Imaging/GDViewer memory leak

Discussions about image processing and document imaging.
Post Reply
cgolban
Posts: 2
Joined: Tue Mar 17, 2009 7:02 pm

Imaging/GDViewer memory leak

Post by cgolban » Tue Mar 17, 2009 7:23 pm

Hi there,

It looks that GDViewer and/or the Imaging control is eating memory and it doesn't return to the previous amount.
After 2-3 hours of continuous work the Windows message "Virtual Memory Too Low" is shown.

Attached you'll find the screen shots from application:
1.jpg - first image
2.jpg - the second image
3.jpg - first image again

The code in that procedure is:

Code: Select all

Call Imaging1.CreateImageFromFile(strFileName(intIndex1).ToString)
Imaging1.AdjustRGB(rulerR.Value, rulerG.Value, rulerB.Value)
Imaging1.ConvertTo1Bpp()
Imaging1.SaveAsTIFF(varNumeFisSelected.Substring(0, varNumeFisSelected.Length - 4) & ".tif", GdPicturePro5.TifCompression.CompressionCCITT4)
Imaging1.CreateImageFromFile(varNumeFisSelected.Substring(0, varNumeFisSelected.Length - 4) & ".tif")
GdViewer1.SetNativeImage(Imaging1.GetNativeImage)
GdViewer1.Terminate()
Imaging1.CloseNativeImage()
I load a color JPEG image in the first line, I generate the B&W TIFF image and finally I load the TIFF image.

Thank you.
Attachments
screenshots.zip
(527.34 KiB) Downloaded 118 times

cgolban
Posts: 2
Joined: Tue Mar 17, 2009 7:02 pm

Re: Imaging/GDViewer memory leak

Post by cgolban » Tue Mar 17, 2009 7:30 pm

I've just added a new line and the memory gap is not completely gone but is obviously smaller.

The new code is:

Code: Select all

Call Imaging1.CreateImageFromFile(strFileName(intIndex1).ToString)
Imaging1.AdjustRGB(rulerR.Value, rulerG.Value, rulerB.Value)
Imaging1.ConvertTo1Bpp()
Imaging1.SaveAsTIFF(varNumeFisSelected.Substring(0, varNumeFisSelected.Length - 4) & ".tif", GdPicturePro5.TifCompression.CompressionCCITT4)
[b]Imaging1.CloseNativeImage()[/b]
Imaging1.CreateImageFromFile(varNumeFisSelected.Substring(0, varNumeFisSelected.Length - 4) & ".tif")
GdViewer1.SetNativeImage(Imaging1.GetNativeImage)
GdViewer1.Terminate()
Imaging1.CloseNativeImage()

User avatar
guruross
Posts: 47
Joined: Tue Jul 22, 2008 11:14 pm
Location: Redding, CA, USA
Contact:

Re: Imaging/GDViewer memory leak

Post by guruross » Mon Apr 13, 2009 8:14 pm

In general, from my experience with the GDPicture library, you must explicitly close all image handles that you open (pretend your developingin C or C++). The default garbage collection and memory handling that VB provides does not catch any open images, which can lead to orphaned file locks, access permission issues, and memory leaks in your software.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests