We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

PDF Generation with PdfTrueTypeFont: memory issues

Hi,

we are using PDF generation in Xamarin.iOS and we found some memory problems when generating the pdf using PdfTrueTypeFont, with version 13.3451.0.7 Suncfusion.*.Portable.dll. 

We use arialuni.ttf (comes with Windows as Arial Unicode).

Well, when our app starts and the memory consumption is low, the generation goes well. Using Instruments, the memory appears to be at aceptable ranges.

But, if the app is consuming some more memory (i simulate this declaring some byte arrays of ~300 or ~400 MB) and them generate some PDF files, the app crashes because low memory (previously some DidReceiveMemoryWarning occurred but ignored for test purposes). The number of generated pdf files is very low, about 10-15.

In each generation, we are creating a FileStream for de TTF file, and then creating de font. Finally, we dispose the elements.

FileStream  fontStream = new FileStream (Path.Combine (Environment.CurrentDirectory, "ttf", "arialuni.ttf"), FileMode.Open, FileAccess.Read, FileShare.Read)
PdfTrueTypeFont  myFont = new PdfTrueTypeFont (fontStream, 8);

// Generate PDF

if (myFont != null)
{
myFont.Dispose ();
myFont = null;
}
if (fontStream != null)
{
fontStream.Close ();
fontStream.Dispose ();
fontStream = null;
}

The question is, are we doing something wrong? Are fonts correctly disposed or is something more necessary to free the memory used?

We work-arround that, declaring the FileStream and PdfTrueTypeFont static, but we don't like the solution at all.

Thanks in advance,
Benito.

5 Replies

PH Praveenkumar H Syncfusion Team October 29, 2015 10:06 AM UTC

Hi Benito,

Thank you for using syncfusion products,

We are not able to reproduce the memory issue, we have created font 1000 times and never get any exception, please find the attached sample project, can you please share us your sample which reproduces the issue. it will help us to investigate further in this.

http://www.syncfusion.com/downloads/support/forum/120950/ze/PDFFontTest-1500681642.zip

With Regards,
Praveen


BG Benito Gomez October 29, 2015 12:33 PM UTC

Hi Praveenkumar,

thanks for your time.

I tested your test project and didn't found memory problems. That's Ok. 

The problems comes when the app is consuming an important amount of memory. Then, when the pdf are generated the application crash. No OutOfMemoryException are  raised and i don't know how control this crash.

For now, we are keeping some static variables with the fonts we use, fortunately we only use 1 rtf so that solutions comes well for us.

I modified your sample and added new button for allocate some memory (this case about 500 Mb). Then, you can push "Generate PDF" and the app will crash (or may crash).

Thanks.

Attachment: PDFFontTest_85d3d32b.zip


PH Praveenkumar H Syncfusion Team October 30, 2015 06:34 AM UTC

Hi Benito,

Thank you for your update,

We have tried your modified sample and we haven’t get any App crash issues, Please find the attached video screen shot.
http://www.syncfusion.com/downloads/support/forum/120950/ze/Screenshot-1129216611.zip

Can you please increase your application memory so that it will work in high memory consumption state also.

Please let us know if you need further assistance.

With Regards,
Praveen


BG Benito Gomez November 2, 2015 08:08 AM UTC

Hi,

In the simulator the app never crash (or it take a long time to do it) because the simulator has a lot of memory, it's not like a real iPad device. Pleas try the app in a device and you would see how it crashes. We normaly test with an iPad Air Model A-1474.

What do you mean about "increase your application memory"? How can i do it?

Thanks.
Benito.


PH Praveenkumar H Syncfusion Team November 3, 2015 10:01 AM UTC

Hi Benito,

Thank you for your update,

We have tried the sample in IPod device and the application get crashed when clicked the button Allocate, it clearly shows that the application takes lot of memory so it crashed.

When I clicked only Generate PDF button alone application not crashed and worked fine and we are properly disposing the memory internally, so it is not an issue from our side.

Here I mentioned the actual device memory as application memory, when you close other applications you can retrieve some memory to the current running application.

With Regards,
Praveen

Loader.
Live Chat Icon For mobile
Up arrow icon