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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Memory Leak in DebenuPDFLibrary?
  FAQ FAQ  Forum Search   Register Register  Login Login

Memory Leak in DebenuPDFLibrary?

 Post Reply Post Reply
Author
Message
rmbarbosa View Drop Down
Beginner
Beginner


Joined: 05 Aug 16
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote rmbarbosa Quote  Post ReplyReply Direct Link To This Post Topic: Memory Leak in DebenuPDFLibrary?
    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
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
dky View Drop Down
Beginner
Beginner


Joined: 27 Oct 20
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote dky Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
dky View Drop Down
Beginner
Beginner


Joined: 27 Oct 20
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote dky Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store