Page 1 of 1

Docx4j in a jboss application

PostPosted: Tue May 24, 2011 12:58 pm
by martinib
Hi. I'm using Docx4j in a web application deployed on jboss.

Code: Select all
/* tmp is an hibernate object that loads the docx template from a database */
InputStream fileInputStream = new ByteArrayInputStream(tmp.getFile());
LoadFromZipNG load = new LoadFromZipNG();
OpcPackage pkg = load.get(fileInputStream);
ByteArrayOutputStream out = new ByteArrayOutputStream();
SaveToZipFile save = new SaveToZipFile(pkg);
save.save(out);
byte[] bytes = out.toByteArray();
out.close();
return bytes;


But after the execution of this code, the memory consumption of my application raises, and analyzing the memory dumps of the heap memory, i found a lot of doc4x objects no garbage collected.
For example:
Code: Select all
org.docx4j.wml.STBorder (191 objects)
org.docx4j.dml.STShapeType (187 objects)
org.docx4j.dml.STPresetColorVal (140 objects)


Any ideas of what could be the problem?
i think maybe you need more information, please let me know and i will provide it if i can.

thanks,

regards,

Re: Docx4j in a jboss application

PostPosted: Wed May 25, 2011 1:38 am
by jason
Not sure.. does memory use change if you explicitly set pkg=null, save=null, and then GC?

javax.xml.bind.JAXBContext.Context stores the various JAXBContexts statically, but it doesn't look like that accounts for the objects you are seeing.

Re: Docx4j in a jboss application

PostPosted: Fri May 27, 2011 6:51 am
by martinib
thank you very much for your response.

Even if i set the variables to null the objects are still on memory.
i have the memory dump but is a 500mb file.
Any tests i could try?

regards,

Re: Docx4j in a jboss application

PostPosted: Thu Jun 09, 2011 3:25 pm
by jason
It seems the unmarshaller may be holding on to objects after it is done. See http://stackoverflow.com/questions/5186 ... marshaller