Paulo,

You're kidding, right? What if the Java heap is only 128mb?

        c

On Fri, Jun 08, 2007 at 03:41:58PM +0100, 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/


-------------------------------------------------------------------------
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/

Reply via email to