Yes, this is a good suggestion, it looks like the JVM is statically caching some information related to custom media (i.e. Paper). There’s not really anywhere where it looks like PDFBox could be responsible for this. It certainly wouldn’t be the first JVM bug we’ve found...
-- John On 11 Apr 2014, at 21:50, Tilman Hausherr <[email protected]> wrote: > Another thought: > Would it work if you use only one paper object, i.e. do "new Paper()" only > once? > > Tilman > > Am 10.04.2014 17:29, schrieb Joseph Siddal: >> Hi Maruan, >> >> The code to reproduce it is: >> >> import org.apache.pdfbox.rendering.printing.Scaling; >> import org.apache.pdfbox.rendering.printing.Orientation; >> import org.apache.pdfbox.pdmodel.PDDocument; >> import org.apache.pdfbox.rendering.PDFPrinter; >> >> import java.awt.print.Paper; >> >> public class PdfBoxExample { >> >> public static void main(String[] args) throws Exception { >> String fileName = args[1]; >> >> while (true) { >> Paper paper = new Paper(); >> int width = 4, height = 6; >> paper.setSize(width * 72, height * 72); >> paper.setImageableArea(0, 0, width * 72, height * 72); >> PDDocument pdf=PDDocument.load(fileName); >> PDFPrinter printer = new PDFPrinter(pdf, Scaling.SCALE_TO_FIT, >> Orientation.AUTO, paper); >> printer.silentPrint(); >> pdf.close(); >> System.gc(); >> } >> } >> >> } >> >> >> >> On 10 April 2014 16:15, Maruan Sahyoun <[email protected]> wrote: >> >>> Hi Joseph, >>> >>> the attachments didn't make it to the mailing list. Could you upload it to >>> a public location? Id the behavior reproducible with any PDF or only with >>> some. Could you oplad a sample PDF too? >>> >>> BR >>> Maruan Sahyoun >>> >>> Am 10.04.2014 um 13:50 schrieb Joseph Siddal <[email protected]>: >>> >>>> Hi, >>>> >>>> I've found a memory leak that is caused when doing high volumes of >>> printing. >>>> The code that reproduces the bug is attached. The code just continuously >>> sends the same printjob to the default printer. The pdf I'm using is >>> available here. The memory leak is evident after 6mins of running the code. >>> The sun.print.CustomMediaTray has 2 static ArrayList fields which are >>> continuously growing in size going from size 29000 to 10000+ after 6 >>> minutes and continuing to climb. >>>> This is using OSX Mavericks, JDK 1.8.0. >>>> >>>> Any help would be appreciated. >>>> >>>> Regards >>>> Joseph >>> >
