Following on from a previous users' issues with a memory leak in the PDF.Kit, a fix was provided from v5.0 onwards I believe.
We have a requirement to generate a thumbnail from the first page of a PDF document to be uploaded into our Document Management System. Unfortunately, attempting to process large .pdf files (we have a 151Mb .pdf test file), results in a large amount of memory usage that doesn't seem to be getting released.
Here are the contents of our own log file.. the memory usage calculators are based on some helpful info provided when we posted a similar problem with the Aspose.Words (in that forum - http://www.aspose.com/community/forums/291344/aspose.words-memory-issue/showthread.aspx#291344 )
Our .pdf upload log is shown below..
** UPLOAD DOCUMENT (Thumbnail) ** Begin Thumbnail Generation
** UPLOAD DOCUMENT (Thumbnail) ** Document Type .pdf is thumbnail capable,
** UPLOAD DOCUMENT (Thumbnail) ** tmpThumbnailFilename = C:\WINDOWS\TEMP\tmp2EB.jpg
** UPLOAD DOCUMENT (Thumbnail) ** set thumbnail creator
** UPLOAD DOCUMENT (Thumbnail) ** call thumbnail creator
** UPLOAD DOCUMENT (Thumbnail) ** Memory Start: 5716992
** UPLOAD DOCUMENT (Thumbnail) ** thumbnail created, now upload
** UPLOAD DOCUMENT (Thumbnail) ** Begin Thumbnail upload to SQL Filestream
** UPLOAD DOCUMENT (Thumbnail) ** clear sqlCommand.Parameters
** UPLOAD DOCUMENT (Thumbnail) ** Begin Thumbnail Upload transaction
** UPLOAD DOCUMENT (Thumbnail) ** Save tmpThumbnail as JPEG
** UPLOAD DOCUMENT (Thumbnail) ** setup DM_InsertThumbnailFileData sp Parameters. DocID = 4760, DocVersionID = 1
** UPLOAD DOCUMENT (Thumbnail) ** executed DM_InsertThumbnailFileData
** UPLOAD DOCUMENT (Thumbnail) ** DataReader has values
** UPLOAD DOCUMENT (Thumbnail) ** loaded DataReader values into local variables and close reader
** UPLOAD DOCUMENT (Thumbnail) ** Start: OpenSQLFilestream into SafeFileHandle
** UPLOAD DOCUMENT (Thumbnail) ** Success: OpenSQLFilestream into SafeFileHandle
** UPLOAD DOCUMENT (Thumbnail) ** Create new Filestream (dbStream2) for SQL Filestream operation
** UPLOAD DOCUMENT (Thumbnail) ** Open new Stream (tmpBmpStream) for tmpThumbnail read operation
** UPLOAD DOCUMENT (Thumbnail) ** Begin: SQL Filestream Write operation
** UPLOAD DOCUMENT (Thumbnail) ** End: SQL Filestream Write operation
** UPLOAD DOCUMENT (Thumbnail) ** Close & Dispose: dbStream2, SafeFileHandle, tmpBmpStream
** UPLOAD DOCUMENT (Thumbnail) ** Commit Thumbnail Upload transaction
** UPLOAD DOCUMENT (Thumbnail) ** Returning Transaction for Thumbnail Upload to calling method
** UPLOAD DOCUMENT (Thumbnail) ** Memory End: 164966680
** UPLOAD DOCUMENT (Thumbnail) ** Memory Used: 159249688 = 151MB
Our PDF thumbnail method looks like this..
public System.Drawing.Bitmap GetThumbNail(string pdfFile) {
MemoryStream ms = new MemoryStream();
PdfConverter converter = new PdfConverter();
//Now we do the licensing stuff, which I have removed for brevity
try {
converter.BindPdf(pdfFile);
converter.DoConvert();
//select the 1st page of the pdf file
converter.GetNextImage(ms, System.Drawing.Imaging.ImageFormat.jpeg);
//create bitmap and point at memory stream
Bitmap bmp = new Bitmap(ms);
//close the memory stream
ms.Close();
ms.Dispose();
converter.Close();
converter = null;
return bmp;
} catch (Exception exc) {
ms.Close();
ms.Dispose();
converter.Close();
throw new Exception(ex.Message);
}
}
When executing this method we see massive memory increase during converter.DoConvert() - which is because the whole .PDF file is being loaded I guess... However after this, is when we do not see any memory released..
For our Words issue, I was dealing with Alexey - I set up a Dropbox share with him.. and could re-use that to provide a copy of the .pdf test file we're seeing issues with..
All help gratefully appreciated :-)