Cleaning up large amounts of data

V

volt9000

I'm using PdfSharp (an open-source PDF manipulation library) to
generate a very large PDF ( 1500+ pages.) My program crashes before
reaching the end because of the massive amounts of memory being used
(after 750 entries the memory footprint is ONE GIGABYTE.)

So I've gotten around this by splitting up the word: every X number of
entries, I close the PDF and start a new one, with the intention of
combining the PDFs at the end. The problem is, after all is said and
done, the memory footprint of the program is still quite large (nearly
200MB) despite my attempts to release the object. I've tried several
methods including trying to force the garbage collector (GC.Collect()
and GC.WaitForPendingFinalizers()) but nothing seems to help.

How can I release the memory?
 
S

Serge Baltic

Hello,
The problem is, after all is said and
done, the memory footprint of the program is still quite large (nearly
200MB) despite my attempts to release the object.

What exactly kind of memory is that? Virtual, commit charge, managed memory?
The metric to check is GC.GetTotalMemory(true) (assuming that the free pdf
component is all managed code). If the managed memory is low, but the commit
charge is high, that's OK and not necessary a leak. That will be reused by
..NET.

If the managed memory is high, you could take some Memory Profiling tool
(I'd use dotTrace) and check the objects that are not being collected. If
they're being held by the pdf component, there's not much that can be done
without editing its code, I'm afraid …

PS. BTW, there's the XPS format that basically counters the PDF functionality,
but is powered by Microsoft and highly integrates with .NET, like, there
are framework classes for generating those documents. Maybe that could serve
as a working alternative for you.

(H) Serge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top