Hi All,

 

I’m generating a Book (PDF file) using Java. The book is made of several existent pdf files (mostly images) as pages and when this book reaches a significant amount of MBs I’m running out memory. Checking the process using OptimizeIt in JBuilder I’m noticing that PDFReader is not “garbage collecting” this object causing the application to hang because of the memory problem. If Increase the memory I’m able to finish the process but I don’t think that should be the solution since we consider that what the JVM has now is good enough. By the way, the size of the last book (it varies based on different business needs) 96 MB.

 

The following is the approach I taking (not actual code):

Document  mainDocument = new Document(PageSize.LETTER, 36, 36, 36, 36);

FileOutputStream  book = new FileOutputStream(outputFile);

PdfCopy  pdfCopy = new PdfCopy(mainDocument, book);

mainDocument.open();

 

            PdfReader pdfReader = new PdfReader(currentPdfFile); ==è here’s where OptimizeIt is showing the memory leak.

            PdfImportedPage importedPage = pdfCopy.getImportedPage(pdfReader, 1);

            pdfCopy.addPage(importedPage);

 

mainDocument.close();

 

 

TIA,

 

Elvis Novas

 

Reply via email to