PdfAddTrueTypeFont OutOfMemory

Discussions about PDF management.
Post Reply
payne296
Posts: 22
Joined: Wed Jul 07, 2010 5:25 pm

PdfAddTrueTypeFont OutOfMemory

Post by payne296 » Wed Apr 20, 2011 9:20 pm

Hey all,

I'm creating a massive batch of pdfs, and about 6000 in I get an OutOfMemory exception when trying to add a font. This isn't actually a memory issue, and my assumption is that the GDI handles aren't being disposed for the fonts and it's running out of handles. I add three fonts per PDF, and if I comment one of them out I can make it to around 8,000 before the error occurs.

I call PdfEndPdf at the end of every PDF, but is there some other way to dispose of all PDF resources or all GdPictureImaging resources so I can avoid this issue?

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: PdfAddTrueTypeFont OutOfMemory

Post by Loïc » Thu Apr 21, 2011 11:14 am

Hi,

I identified a small unreleased GDI resource in this method :mrgreen:.
Maybe it is the cause of the problem. The next update, which will be published within 5 days will include the fix.

Kind regards,

Loïc

payne296
Posts: 22
Joined: Wed Jul 07, 2010 5:25 pm

Re: PdfAddTrueTypeFont OutOfMemory

Post by payne296 » Thu Apr 21, 2011 6:37 pm

Thanks Loic, I'm not sure why GDI has to be so finnicky.

payne296
Posts: 22
Joined: Wed Jul 07, 2010 5:25 pm

Re: PdfAddTrueTypeFont OutOfMemory

Post by payne296 » Wed Apr 27, 2011 2:19 pm

Is this update still on track for this week?

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: PdfAddTrueTypeFont OutOfMemory

Post by Loïc » Wed Apr 27, 2011 5:28 pm

Hi,

Yes it will be published within 48 hours.

Kind regards,

Loïc

payne296
Posts: 22
Joined: Wed Jul 07, 2010 5:25 pm

Re: PdfAddTrueTypeFont OutOfMemory

Post by payne296 » Thu Apr 28, 2011 4:21 pm

The problem still exists. I don't think the issue is actually with the PdfAddTrueTypeFont method, but with the fact that the font that is added with that method is not disposed with PdfEndPdf. Here is, in short, what I'm doing.

Code: Select all

for (int i = 0; i < paths.Length; i++)
{
   int pdf = gdPictureImaging.PdfNewPdf(paths[i]);
   int arialBold = gdPictureImaging.PdfAddTrueTypeFont(pdf, "Arial", true, false);
   int arialPlain = gdPictureImaging.PdfAddTrueTypeFont(pdf, "Arial", false, false);
   int timesNewRoman = gdPictureImaging.PdfAddTrueTypeFont(pdf, "Times New Roman", false, false);

   ... pdf code...

   gdPictureImaging.PdfEndPdf(pdf);
}
I leak three GDI objects every iteration. My assumption was that PdfEndPdf would deallocate those fonts, but that doesn't seem to be happening. Is there any other way for me to deallocate those resources?

Any help would be appreciated, this is a huge issue for me.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: PdfAddTrueTypeFont OutOfMemory

Post by Loïc » Thu Apr 28, 2011 5:34 pm

Hi,

I am sorry to heard that. Anyway I have finally been able to reproduce the problem. i think it is definitively fixed now.
I will publish an urgent fix tomorrow, if you want a most urgent fix and better follow-up just send us a mail to https://www.gdpicture.com/support/getting-support-from-our-team

Kind regards,

Loïc

payne296
Posts: 22
Joined: Wed Jul 07, 2010 5:25 pm

Re: PdfAddTrueTypeFont OutOfMemory

Post by payne296 » Thu Apr 28, 2011 6:34 pm

Thanks Loic, tomorrow should be fine. I appreciate the quick response!

payne296
Posts: 22
Joined: Wed Jul 07, 2010 5:25 pm

Re: PdfAddTrueTypeFont OutOfMemory

Post by payne296 » Fri Apr 29, 2011 3:41 pm

Working like a charm now, thanks for the help!

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: PdfAddTrueTypeFont OutOfMemory

Post by Loïc » Fri Apr 29, 2011 3:44 pm

OK perfect,
I made the test with 1.000.000 of documents with 0 byte of memory leak ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests