Nested PdfPTable table memory leak.
Memory leak while creating a large table with more than 5000 rows and and 3
columns. Each cell of the table will
have a nested table of 2 rows and 5 columns each. Could anyone help me with
this. This is the piece of code that
does the creation of table:
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.PageSize;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
public class PdfHeapTest {
public static void main(String[] args) {
try {
Document document = new Document();
document.setPageSize(PageSize.A4);
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream("c:\\h1.pdf"));
document.open();
int rows = 5701/1;
int columns = 3;
int innerTableRows = 2;
int innerTableColumns = 5;
PdfPTable table = new PdfPTable(columns+1);
for(int j=0;j<rows;j++){
table.addCell(new Phrase("Row"+j));
for(int i=0;i<columns;i++){
PdfPTable inner = new
PdfPTable(innerTableColumns);
for(int
k=0;k<innerTableRows;k++){
inner.addCell(new
Phrase("A"+j));
inner.addCell(new
Phrase("B"+j));
inner.addCell(new
Phrase("C"+j));
inner.addCell(new
Phrase("D"+j));
inner.addCell(new
Phrase("E"+j));
}
table.addCell(inner);
System.out.println("Row "+ j
+" Successfully added");
}
}
document.add(table);
document.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
}
}
Thanks in advance,
Regards,
Prakash
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php