Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
Memory Leak in DebenuPDFLibrary? |
Post Reply |
Author | |
rmbarbosa
Beginner Joined: 05 Aug 16 Status: Offline Points: 2 |
Post Options
Thanks(0)
Posted: 05 Aug 16 at 3:53AM |
Hello good people,
I have a pdf file with 200 pages or more. I'm extracting/rendering each page as a TIFF file. The problema is when using the code below the heap memory just gets bigger and bigger and eventually throws an out of memory exception. ---- sample code--- PdfLib.LoadFromFile(filename, null); var documentId = PdfLib.SelectedDocument(); var pageCount = PdfLib.PageCount(); for(int i=0;i<pageCount;i++) { PdfLib.SelectPage(i); var tempFileName="....."; // custom filename // 7 = TIFF (LZW) output PdfLib.RenderPageToFile(300, i, 7, tempFileName); } ----- each time the RenderPageToFile is called the memory increases 2MB and i dont know of a way to release it other than unload the document and reload it again (for each x pages for example) wich is not a very elegante way of doing this. What i'm i missing? Is it a bug? or my pseudo-code is wrong? Im using the 32bit dll .net version and c# with DebenuPDFLibraryDLL1014 but i've tried with the latest version and the behaviour is exactly the same. any help? Edited by rmbarbosa - 05 Aug 16 at 3:58AM |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi RM,
perhaps it's better to use the DARender...functions. Or the RenderToStream... ToString... and the save at the end: http://www.debenu.com/docs/pdf_library_reference/RenderingAndPrinting.php Cheers and welcome here, Ingo |
|
Cheers,
Ingo |
|
dky
Beginner Joined: 27 Oct 20 Status: Offline Points: 12 |
Post Options
Thanks(0)
|
I also received an error message "Out of memory while expanding memory Stream" after calling RenderPageToFile() continuously to extract more than about 10 pages from PDF pages to TIF image.
What can I do ? I can't find release function to release memory after each extraction. Thanks you.
|
|
dky
Beginner Joined: 27 Oct 20 Status: Offline Points: 12 |
Post Options
Thanks(0)
|
Dear Ingo,
I also received an error message "Out of memory while expanding memory Stream" after calling RenderPageToFile() continuously to extract more than about 10 pages from PDF pages to TIF image.
What can I do ? I can't find release function to release memory after each extraction. Thanks you. |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi Dan :)
How to free memory you can read here: https://www.oreilly.com/library/view/delphi-in-a/1565926595/re116.html Or you can try Google with "FreeMem Delphi". Using the QuickPDF-functions you can always free memory like below: Hint 1: try QP := TDebenuPDFLibrary1822.Create; try QP.LoadFromFile(xFileName, ''); // . . . finally QP.Free; // <--- // . . . end; except QP.Free; // <--- // . . . end; Hint 2: function Get...; var Stream: TMemoryStream; //. . . begin try Stream := TMemoryStream.Create; // . . . finally Stream.Free; // <--- end; end; |
|
Cheers,
Ingo |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store