PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Jul 11, 2024 8:24 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed May 18, 2011 1:01 pm 
Offline

Joined: Wed May 18, 2011 12:47 pm
Posts: 2
We use a Backend-application to merge and transfer PDF-files on our server.

First a customer loads a PDF file in separate pages to our server. It is placed in a Jobs-directory.
When the transfer is complete our Backend-application merges the PDF files to one large PDF file.
It then transfers the PDF file to a other location on the server.

Smaller PDF files are no problem, but when merging a large PDF file(1,2gb and up). We get the following message:



System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at PdfSharp.Pdf.PdfDictionary.PdfStream.Clone()
at PdfSharp.Pdf.PdfDictionary.Copy()
at PdfSharp.Pdf.PdfObject.Clone()
at PdfSharp.Pdf.PdfObject.ImportClosure(PdfImportedObjectTable importedObjectTable, PdfDocument owner, PdfObject externalObject)
at PdfSharp.Pdf.PdfPages.CloneElement(PdfPage page, PdfPage importPage, String key, Boolean deepcopy)
at PdfSharp.Pdf.PdfPages.ImportExternalPage(PdfPage importPage)
at PdfSharp.Pdf.PdfPages.Insert(Int32 index, PdfPage page)
at PdfSharp.Pdf.PdfDocument.AddPage(PdfPage page)
at ChrisRussell.Core.PDF.PDFEditor.MergePDFs(String[] pages, String filename) in D:\Source\ChrisRussell\_lib\ChrisRussell.Core.PDF\PDFEditor.cs:line 61
at ChrisRussell.Data.DataChunk.PrepareForPrinting(OrderLine orderLine, Int32 ChunkId, BarcodeLocation barcodeLocation, PrinterQueue printerQueue) in D:\Source\ChrisRussell\_lib\ChrisRussell.Data\DataChunk.cs:line 200
at ChrisRussell.Data.Upload.PrepareForPrinting(OrderLine orderLine, OrderLineChunk ol, BarcodeLocation bl) in D:\Source\ChrisRussell\_lib\ChrisRussell.Data\Upload.cs:line 320
at ChrisRussell.Data.Upload.PreperareForPrinting(OrderLine orderLine) in D:\Source\ChrisRussell\_lib\ChrisRussell.Data\Upload.cs:line 274
at ChrisRussell.Data.OrderLine.PrepareForPrinting() in D:\Source\ChrisRussell\_lib\ChrisRussell.Data\OrderLine.cs:line 302
at ChrisRussell.Data.Order.PrepareForPrinting() in D:\Source\ChrisRussell\_lib\ChrisRussell.Data\Order.cs:line 741
at ChrisRussell.BackEnd.Program.Main()


Trying to solve the problem we've bought a new 64bit 4 processor server with 12gb RAM. This didn't solve the problem.

The stacktrace shows that "PdfSharp.Pdf.PdfDictionary.PdfStream.Clone()" produces the problem. Can anyone tell me how we can solve the problem?


Top
 Profile  
Reply with quote  
PostPosted: Wed May 18, 2011 2:40 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
I presume you made sure that your application is running as a 64 bit process (32 bit processes are limited to 2 or 3 GB).

Increasing GDIProcessHandleQuota might help.
See the first post by "Mark Wilson-Thomas" in this thread:
http://social.msdn.microsoft.com/forums ... 8be25d5c4/

Switching from GDI+ to WPF mode or vice versa could make a difference.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu May 19, 2011 10:32 am 
Offline

Joined: Wed May 18, 2011 12:47 pm
Posts: 2
Hello Thomas,

Thanks for your reaction.

The application is a console application. So it's not an WPF application

To illustrate te problem, I've added screenshots:
http://img860.imageshack.us/i/beforeg.jpg/
You See the application waiting for a PDF File to merge/waiting for an order. The memory use is low.

http://img23.imageshack.us/i/before1e.jpg/
Still waiting for an order. here you see the memory use of the application


http://img856.imageshack.us/i/aftero.jpg/
You see the application has a outofmemoryexeption . The memory usage is high

http://img690.imageshack.us/i/after2l.jpg/
You see the application has a outofmemoryexeption . The memory usage is high

The screenshots show the memory flows on the server.


greetz


Top
 Profile  
Reply with quote  
PostPosted: Thu May 19, 2011 11:19 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
stephanrussell wrote:
The screenshots show the memory flows on the server.

Global memory usage goes up from 39 % to 50 %.
And your application is 32 bit, so it's limited to 2 GB.

50 % server memory free, but your app gets an OutOfMemory exception.

AFAIK you can use both GDI+ and WPF builds of PDFsharp with console application.

So first step: build a 64 bit version of your app and try that.
Second step: switch from GDI+ to WPF or vice versa to see if that makes a difference.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group