Memory leak?
Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1726
Printed Date: 03 Jul 25 at 10:52AM Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com
Topic: Memory leak?
Posted By: hansmerkl
Subject: Memory leak?
Date Posted: 05 Feb 11 at 10:22PM
The following C# code runs out of memory with even medium sized files. After calling DACloseFile the memory gets released. Am I missing something that has to be released?
QuickPDFAX0723.PDFLibrary Lib = new QuickPDFAX0723.PDFLibrary(); Lib.UnlockKey("xxxx");
string fnIn = this.buttonEditPDF.Text; int DocHandle = Lib.DAOpenFileReadOnly(fnIn, "");
int PageCount = Lib.DAGetPageCount(DocHandle); for (int i = 0; i < PageCount; i++) { int PageHandle = Lib.DAFindPage(DocHandle, i + 1);
int ImageListHandle = Lib.DAGetPageImageList(DocHandle, PageHandle); int ImageCount = Lib.DAGetImageListCount(DocHandle, ImageListHandle);
for (int ii = 0; ii < ImageCount; ii++) { var ImageBuffer = Lib.DAGetImageDataToVariant(DocHandle, ImageListHandle, ii + 1); byte[] b = ImageBuffer as byte[]; } }
MessageBox.Show("Done");
Lib.DACloseFile(DocHandle);
|
Replies:
Posted By: Ingo
Date Posted: 06 Feb 11 at 12:29PM
Hi Hans!
After DACloseFile The "Free" should follow. You can read here sometimes about memory-problems as a result based on DAFindPage.
I've an old workaround to avoid this: Using a counter like this (for a loop in a loop) ...
QP := TQuickPDF0721.Create; // . . . pc := pc + 1; if ( pc = 5 ) Then begin pc := 0; QP.Free; QP := TQuickPDF0721.Create; // QP.UnlockKey('MyKey...'); // . . . end; // . . . QP.Free;
|
Posted By: hansmerkl
Date Posted: 06 Feb 11 at 7:39PM
It's a good idea to close to the file from time to time. I hope the performance won't suffer too much.
I hope QuickPDF are aware of the DAFindPage problem and will fix it soon.
|
Posted By: Ingo
Date Posted: 06 Feb 11 at 8:15PM
Hi!
The DAFindPage-prob is already an older one and so i don't think that it will be fixed soon ;-) But you can avoid the DA-functions. Use the "normal" ones and with the current library version you won't have any disadvantages.
Cheers, Ingo
|
Posted By: hansmerkl
Date Posted: 06 Feb 11 at 8:27PM
That's probably the way to go.
|
|