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?
  FAQ FAQ  Forum Search   Register Register  Login Login

Memory leak?

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


Joined: 05 Feb 11
Location: USA
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote hansmerkl Quote  Post ReplyReply Direct Link To This Post Topic: Memory leak?
    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);
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

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



Edited by Ingo - 06 Feb 11 at 12:30PM
Back to Top
hansmerkl View Drop Down
Beginner
Beginner


Joined: 05 Feb 11
Location: USA
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote hansmerkl Quote  Post ReplyReply Direct Link To This Post 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.


Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3529
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
hansmerkl View Drop Down
Beginner
Beginner


Joined: 05 Feb 11
Location: USA
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote hansmerkl Quote  Post ReplyReply Direct Link To This Post Posted: 06 Feb 11 at 8:27PM
That's probably the way to go.
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