We have recently begun to use Aspose.PDF for conversion of PDF pages to TIFF. With large files we are experiencing instances where we run out of memory. We have tried disposing of the Aspose.PDF.Document as well as setting the TiffSettings and TiffDevice to nothing (they don’t have dispose options). We also have tried forcing .NET garbage collection after cleaning up the objects. Then we have to recreate them for every page being processed. Is there another way to force the memory to be cleaned up that we are missing? Thanks in advance.
We have been processing one page a time. I did try to render all of the pages at the same time. I had the same problem running out of memory. I will attach the file that I am working with and also try other files to make sure that this isn’t just related to this one file. I don’t think so though because as I watch the memory while processing it simply grows each time any page is processed.
We also tried using a stream instead of writing to a file. Then disposing of the stream when we were finished with it. Still have the same problem.
We are using the .NET platform.
We have no problem processing one page at a time as long as using the dispose methods will clean up the memory. It is difficult to have to close our exe each time to render a set of pages. If the memory grew that is ok as long as dispose or a new method would release it…
Document pdfDocument = new Document("input.pdf");
int pageCount = 1;
//loop through all the pages
foreach (Page pdfPage in pdfDocument.Pages)
Document newDocument = new Document();
newDocument.Save("page_" + pageCount + ".pdf");
'Sample code would be something like this. The difference is we are concerned about a leak in the TIFFDevice object. I simplied this but this should be a good example to demonstrate the leak.
With this example going page by page you can see how the memory grows if you step through it.
It has to be something I am doing outside of this code I assume since if I create a fresh project with only this code it works. I will keep working on it. Thanks for helping though since this did at least rule out the library as the source now.
Unfortunately I am unable the resolve the issue so far after dedicating several full days to it. Whenever I call Aspose.PDF from the assembly where I need it I get a memory leak on the tiffdevice.Process call. If I create a clean WinForm project and call a class module project that hosts Aspose.PDF I don’t have the issue. But if call Aspose.PDF from the assembly where I need it I will have the leak for every page processed. I quickly run out of memory.
I am working to try to create a sample that I can send you that reproduces it. I am trying to figure out what is different. This may take some time.