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? 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
_________________________________________________________________
Skaffa nya Windows Live Messenger!
http://get.live.com/messenger/overview-------------------------------------------------------------------------
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/