The problem is that GC takes resources from the server. During a 21 minutes test we created 434 PDF-files from scratch using PdfPTable and 284 GC's were started. On a website with many customers this really affects the overall performance. During the GC the server is occupied with that and other applications will have to wait. But anyhow, the Table class seems to be more memory friendly so I will try to implement it instead of PdfPTable.
The PDF file with a size of 22 kb and 6 pages has 306 rows with 7 columns. 130 MB were allocated during the build. We are running on IBM WebSphere Application Server, V6.1 on Mainframe z/OS Statistics from the GC log: <AFí277ù: Allocation Failure. need 8208 bytes, 4705 ms since last AF> <AFí277ù: managing allocation failure, action=1 (6168/268165488) (268432/268432)> <GC(277): GC cycle started Thu May 31 14:14:30 2007 <GC(277): freed 204633320 bytes, 76% free (204907920/268433920), in 209 ms> <GC(277): mark: 188 ms, sweep: 21 ms, compact: 0 ms> <GC(277): refs: soft 0 (age >= 32), weak 0, final 20, phantom 0> <AFí277ù: completed in 211 ms> <AFí278ù: Allocation Failure. need 8208 bytes, 562 ms since last AF> <AFí278ù: managing allocation failure, action=1 (1816288/268165488) (268432/268432)> <GC(278): GC cycle started Thu May 31 14:14:31 2007 <GC(278): freed 202585576 bytes, 76% free (204670296/268433920), in 188 ms> <GC(278): mark: 170 ms, sweep: 18 ms, compact: 0 ms> <GC(278): refs: soft 0 (age >= 32), weak 0, final 11, phantom 0> <AFí278ù: completed in 188 ms> <AFí279ù: Allocation Failure. need 8208 bytes, 5545 ms since last AF> <AFí279ù: managing allocation failure, action=1 (0/268165488) (268432/268432)> <GC(279): GC cycle started Thu May 31 14:14:36 2007 <GC(279): freed 201476216 bytes, 75% free (201744648/268433920), in 199 ms> <GC(279): mark: 176 ms, sweep: 23 ms, compact: 0 ms> <GC(279): refs: soft 0 (age >= 32), weak 0, final 15, phantom 0> <AFí279ù: completed in 200 ms> <AFí280ù: Allocation Failure. need 8208 bytes, 5729 ms since last AF> <AFí280ù: managing allocation failure, action=1 (4752/268165488) (268432/268432)> <GC(280): GC cycle started Thu May 31 14:14:42 2007 <GC(280): freed 204400336 bytes, 76% free (204673520/268433920), in 191 ms> <GC(280): mark: 169 ms, sweep: 22 ms, compact: 0 ms> <GC(280): refs: soft 0 (age >= 32), weak 0, final 16, phantom 0> <AFí280ù: completed in 191 ms> <AFí281ù: Allocation Failure. need 8208 bytes, 1092 ms since last AF> <AFí281ù: managing allocation failure, action=1 (11808/268165488) (268432/268432)> <GC(281): GC cycle started Thu May 31 14:14:44 2007 <GC(281): freed 204593984 bytes, 76% free (204874224/268433920), in 192 ms> <GC(281): mark: 171 ms, sweep: 21 ms, compact: 0 ms> <GC(281): refs: soft 0 (age >= 32), weak 0, final 18, phantom 0> <AFí281ù: completed in 193 ms> Paulo Soares wrote: > > What's the problem? The GC takes care of that. > > Paulo > >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On >> Behalf Of greggan1 >> Sent: Friday, June 08, 2007 9:17 AM >> To: [email protected] >> Subject: [iText-questions] High memory allocation with PdfPTable >> >> >> Hi >> >> I have tested your >> http://itextdocs.lowagie.com/tutorial/objects/tables/pdfptable >> /index.html#memory >> and analyzed the memory allocation during the build with NuMega from >> Compuware. The result shows that 205 MB are used and about >> 575 thousand >> objects are temporarily created for the result, a pdf with a >> size of 53kb. >> The method BidiLine() used about 182 MB of memory. >> >> >> >> I then tried the older Table class and did the same loop with >> the result >> that 22 MB of memory were allocated and 610 thousand objects created. >> >> >> I'm using itext-2.0.0.jar. >> >> >> Should it be like this? Or is it a bug in PdfPTable? Or >> shouldn't itext be >> used as a server side solution? I'm planning to use this on a >> web site with >> many users creating pdf's but it will make the server running >> very slow. The >> server must garbage collect immediately after a pdf is created. >> >> Temporary Bytes including Children: 210,014,040 Bytes >> Temporary Objects including Children: 590,701 >> >> PdfPTable >> Size of PDF: 53 kb >> public void fragmentTable() >> { >> System.out.println("FragmentTable"); >> int fragmentsize = 50; >> // step1 >> Document document = new >> Document(PageSize.A4.rotate(), 10, 10, 10, >> 10); >> try { >> // step2 >> PdfWriter.getInstance(document, >> new >> FileOutputStream("FragmentTable.pdf")); >> // step3 >> document.open(); >> // step4 >> >> PdfPTable table = new PdfPTable(2); >> table.setWidthPercentage(100f); >> >> PdfPCell cell; >> for (int row = 1; row <= 2000; row++) { >> if (row % fragmentsize == 0) { >> document.add(table); >> table.deleteBodyRows(); >> table.setSkipFirstHeader(true); >> } >> cell = new PdfPCell(new >> Paragraph(String.valueOf(row))); >> table.addCell(cell); >> cell = new PdfPCell(new >> Paragraph("Hello World")); >> table.addCell(cell); >> } >> document.add(table); >> } catch (Exception de) { >> de.printStackTrace(); >> } >> // step5 >> document.close(); >> } >> Temporary Bytes including Children: 205,371,200 Bytes >> Temporary Objects including Children: 575,385 >> >> >> >> The memory allocation is the same if you skip the part with " >> if (row % >> fragmentsize == 0) { ...... >> >> >> >> Method: BidiLine.BidiLine() >> Package: com.lowagie.text.pdf >> View Call Graph >> View Source Code >> Execution Count: 8,040 >> Temporary Bytes: 182,797,440 Bytes >> Temporary Objects: 80,400 >> >> >> >> >> >> Table >> >> Size of PDF: 68 kb >> public void oldFragmentTable() >> { >> System.out.println("FragmentTable2"); >> int fragmentsize = 50; >> // step1 >> Document document = new >> Document(PageSize.A4.rotate(), 10, >> 10, 10, 10); >> try { >> // step2 >> PdfWriter.getInstance(document, >> new >> FileOutputStream("FragmentTable2.pdf")); >> // step3 >> document.open(); >> // step4 >> >> Table table = new Table(2); >> table.setWidth(100f); >> >> Cell cell; >> for (int row = 1; row <= 2000; row++) { >> cell = new Cell(String.valueOf(row)); >> table.addCell(cell); >> cell = new Cell("Hello World"); >> table.addCell(cell); >> } >> document.add(table); >> } catch (Exception de) { >> de.printStackTrace(); >> } >> // step5 >> document.close(); >> } >> Temporary Bytes including Children: 22,476,600 Bytes >> Temporary Objects including Children: 610,873 >> >> >> >> Method: PdfDocument.add(com.lowagie.text.pdf.PdfTable, boolean) >> Package: com.lowagie.text.pdf >> >> View Call Graph >> View Source Code >> Temporary Bytes: 6,608,088 Bytes >> Temporary Objects: 191,496 >> >> //greggan > > > Aviso Legal: > Esta mensagem é destinada exclusivamente ao destinatário. Pode conter > informação confidencial ou legalmente protegida. A incorrecta transmissão > desta mensagem não significa a perca de confidencialidade. Se esta > mensagem for recebida por engano, por favor envie-a de volta para o > remetente e apague-a do seu sistema de imediato. É proibido a qualquer > pessoa que não o destinatário de usar, revelar ou distribuir qualquer > parte desta mensagem. > > Disclaimer: > This message is destined exclusively to the intended receiver. It may > contain confidential or legally protected information. The incorrect > transmission of this message does not mean the loss of its > confidentiality. If this message is received by mistake, please send it > back to the sender and delete it from your system immediately. It is > forbidden to any person who is not the intended receiver to use, > distribute or copy any part of this message. > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions > Buy the iText book: http://itext.ugent.be/itext-in-action/ > > -- View this message in context: http://www.nabble.com/High-memory-allocation-with-PdfPTable-tf3888321.html#a11034773 Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
