Hi,
Recently we developed a application to generate barcode labels using
itext. However when we performed stress test for 3 users generating 2000
labels each. Server is crashing and it seems native memory seems to be the
issue. This machine has 4GB RAM and java heap set to max of 1.5 GB. I'm
using latest version of itext and java 1.4.2. Here is my code.
ByteArrayOutputSteam baos=new
ByteArrayOutputSteam();
Document doc=new Document(new
Rectangle(500,300),0,0,0,0);
PdfWriter writer = PdfWriter.getInstance(doc,
baos);
writer.setStrictImageSequence(true);
doc.open();
for(int i=0; i<list.size(); i++){
MyObject label=(MyObject)list.get(i);
Barcode39 code=new Barcode39();
code.setCode(label.getCode());
code.setAltText(label.getAlternateText());
code.setBaseline(-6);
code.setBarHeight(code.getBarHeight()*2);
BaseFont
font=BaseFont.createFont("Helvetica", "winansi", false);
code.setFont(font);
code.setSize(15);
code.setTextAlignment(Element.ALIGN_CENTER);
PdfContentByte cb =
writer.getDirectContent();
PdfTemplate image39 =
code.createTemplateWithBarcode(cb, null, null);
cb.addTemplate(image39, 50, 57);
writer.releaseTemplate(image39);
cb.beginText();
cb.setFontAndSize(BaseFont.createFont("Helvetica", "winansi", false), 17);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, label.getDescription(), 150,
37, 0);
cb.endText();
doc.newPage();
}
doc.close();
writer.close();
return baos.toByteArray();
Is there anything that I can do to optimize above code. I tried to generate
labels in small chucks and write it file and later merge the files to
display results. Still got same error.
Thank you and appreciate any help.
Jaggu
--
View this message in context:
http://www.nabble.com/Application-Server-Crashses-due-to-native-memory-exhaustion-tp20334241p20334241.html
Sent from the iText - General mailing list archive at Nabble.com.
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php