PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Jul 10, 2024 4:16 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Jun 17, 2011 11:58 pm 
Offline

Joined: Fri Jun 17, 2011 11:26 pm
Posts: 1
I'm creating a series of barcode catalogs, and am running into an Out of Memory exception when I run my program. I've tried removing the images from the catalog and the memory footprint is WAY smaller, but it still doesn't release any of the memory from the created PDFs until after they're all created. Here's the code I've come up with so far:

Code:
// individualCatalogs is a LiNQ expression pulling what I need from the database.
foreach (var catalog in individualCatalogs.ToList()) {
   using (var pdf = new InventoryOperations().GenerateBarcodeCatalog(catalog)) {
      using (FileStream s = File.Open(String.Format("MyCatalog{1}.pdf", catalog.Name), FileMode.Create)) {
         pdf.Save(s);
         pdf.Close();
         pdf.Dispose();
         s.Close();
         s.Dispose();
      }
   }
   GC.Collect();
}



As you can see, I've tried every trick I can think of to get the PDF to get collected after it's saved to disk. What have you guys tried? I need the barcodes in there too (XImage elements), and that's when things start crashing.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 24, 2011 10:53 am 
Offline

Joined: Wed Jun 15, 2011 11:30 am
Posts: 3
Hi,
Add these lines too

GC.GetTotalMemory(false);
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.GetTotalMemory(true);

Regards,

Balaji.


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 21 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