Print Page | Close Window

Memory Leak in Render

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=206
Printed Date: 16 May 24 at 2:50PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Memory Leak in Render
Posted By: swb1
Subject: Memory Leak in Render
Date Posted: 13 Dec 05 at 5:05PM

Using AQtime to profile a simple application I have found that I loose 8 bytes on every call that uses the Renderer. While this sounds like a small amount of memory.. trust me - it adds up. My application needs to run unattended for months, and it could process thousands of pages every day making several calls to the Renderer per page.

 

This is my sample code:

 

 

procedure TForm1.Button2Click(Sender: TObject);

var quickPDF : TiSEDQuickPDF;

begin

      quickPDF := TiSEDQuickPDF.Create;

      quickPDF.UnlockKey( MY_QDPF_KEY );

      quickPDF.LoadFromFile( 'AnyDocument.pdf' );

      try

            // This call uses renderer to get text details

            Memo1.Lines.Text := quickPDF.GetPageText( 3 );

      finally

            quickPDF.Free;

      end;

end;

 

I have found the offending section of code in uPDFRenderer.pas but I don’t know why this code is creating a leak.

 

This function is found at line 1355 of uPDFRenderer.pas

 

  procedure DrawXObject(const ResName: string);

 

Does anybody have any ideas or suggestions?

 

Thanks

Steve



Replies:
Posted By: swb1
Date Posted: 13 Dec 05 at 6:37PM

Found it!

Unit:uPDFImageDecoder approx Line:1300

Change From :

procedure TPDFImageDecoder.SetColorManager(
NewColorManager: TPDFColorManager);
begin
  FColorManager := NewColorManager; // << This simply assigns a new object to the pointer for an old object that  can now no longer be freed.
  FPrivateColorManager := False;
end;

Change TO:

procedure TPDFImageDecoder.SetColorManager(
NewColorManager: TPDFColorManager);
begin
  FColorManager.Free
  FColorManager := NewColorManager;
  FPrivateColorManager := False;
end;

That's 10 hours of my life I'll never get back

 

 



Posted By: SuperDave
Date Posted: 24 Dec 05 at 4:54AM
Hi Steve,
I am using the renderer too but don't have the source code. Could you please send me your uPDFImageDecoder.dcu file?
Thanks,
Dave
superdave156@yahoo.co.uk


Posted By: Ingo
Date Posted: 24 Dec 05 at 6:21AM
Hi Dave!
Michel will collect the corrections from all users and will offer the dcu-files here in a few days as a download-option.

Merry Christmas and a Happy New Year for all of you.


-------------
Cheers,
Ingo



Posted By: swb1
Date Posted: 24 Dec 05 at 3:49PM

Dave,

If you can wait for Michel you may be better off.  The only DCU that I have is D7 and I am not well equiped to compile other versions at this time.

If D7 is what you need and you just can't wait, let me know and I will send you the DCU.

Steve

 

 



Posted By: Michel_K17
Date Posted: 26 Dec 05 at 11:01AM
Just to be clear: I "only" have Delphi 7, so anything I would compile would only be using that version of Delphi. Would that be a problem for those that use D2005/2006?


Posted By: swb1
Date Posted: 26 Dec 05 at 11:43AM

DCUs are version specific. If you are using D7 and you do not have source code you must have DCUs that were compiled with D7 the same will hold true for D2005 & D2006.

Supplying multiple versions of the DCUs for the group may prove to be a challenge. While I have several versions of Delphi, I don’t usually have more that one version installed at a time. Even though I bought it, I may never install D2005. I will probably just jump to D2006 when I finally get around to upgrading.

 Steve

 



Posted By: Ingo
Date Posted: 26 Dec 05 at 4:51PM
Hi Michel!
I think that's only a problem to users with delphi versions below 7 ;-)
I've d5, d2005 and d2006 installed. ...But 'till now i don't have a source licence ;-)


-------------
Cheers,
Ingo



Posted By: SuperDave
Date Posted: 31 Dec 05 at 5:24AM
I still have D5 as it does everything I need and because upgrading Delphi (I started at Borland Pascal for Windows on Windows 3.1 in 1991) has been so difficult in the past.


Posted By: Ingo
Date Posted: 31 Dec 05 at 9:05AM
Hi Dave,

you can download d2005 for free. The licence is similar to the one from vb express! With the d2005 starter edition you can develope and sell your products as long as you are a single developer (this means a one-man-company).


-------------
Cheers,
Ingo



Posted By: SuperDave
Date Posted: 01 Jan 06 at 3:54AM
That is interesting Ingo. I will download it. Thanks.


Posted By: Wheeley
Date Posted: 01 Jan 06 at 6:25PM
It tried to find this download and failed. Would you happen to have a link?

Thanks
Wheeley


Posted By: Ingo
Date Posted: 02 Jan 06 at 2:07AM
Hi!
Sorry. "Download" wasn't correct. It was a special borland edition on several magazine cds here in germany in march/april 2005.
Perhaps you can go online to your preferred pc magazines and order an older magazine-versions with d2005?



-------------
Cheers,
Ingo



Posted By: Wheeley
Date Posted: 02 Jan 06 at 8:20PM
OK. That explains it. I did see on Borland's site where you could get a key for this version. I'm sorry i missed it. Which magazine was it that you got the version with (if you remember)?

Thanks
Wheeley


Posted By: Ingo
Date Posted: 03 Jan 06 at 2:26AM
Hi Wheeley!

German pc magazins:
"PC Magazin"
"c't"



-------------
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