Print Page | Close Window

Memory Leak in DebenuPDFLibrary?

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=3364
Printed Date: 09 May 24 at 2:02AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Memory Leak in DebenuPDFLibrary?
Posted By: rmbarbosa
Subject: Memory Leak in DebenuPDFLibrary?
Date 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?
 
 



Replies:
Posted By: Ingo
Date Posted: 07 Aug 16 at 7:48PM
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



Posted By: dky
Date Posted: 17 Jan 24 at 3:59PM
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.


Posted By: dky
Date Posted: 17 Jan 24 at 4:01PM
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.


Posted By: Ingo
Date Posted: 20 Feb 24 at 7:54PM
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




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk