Hi,
In our applications heap dump during OutOfMemory errors we consistently see
the following JAXB related objects :
Count Total-size Type Name
-------------------------------------------------------------------------------
4,617,766 184,710,640 com/sun/msv/grammar/InterleaveExp
42 85,121,184 array of com/sun/msv/grammar/Expression
144,490 4,623,680 com/sun/msv/verifier/regexp/OptimizationTag
154,803 3,715,272 com/sun/msv/util/StringPair
154,679 3 ,712,296
com/sun/msv/verifier/regexp/OptimizationTag$OwnerAndCont
This the way we use JAXB :
//----------------UNMARSHALLING
JAXBContext jc = JAXBContext.newInstance
(packageName,JaxbManager.class.getClassLoader());
// create an Unmarshaller
Unmarshaller u = jc.createUnmarshaller();
u.setValidating(true);
return u.unmarshal( new StreamSource(new StringReader(xml)));
//----------------MARSHALLING
StringWriter strWr = new StringWriter();
JAXBContext jc =
JAXBContext.newInstance(packageName,JaxbManager.class.getClassLoader());
//Check for errors
Validator validator = jc.createValidator();
validator.setEventHandler(new ValidationEventCollector());
validator.validateRoot(jaxbRoot);
ValidationEventCollector validationColl =
(ValidationEventCollector)validator.getEventHandler();
if(validationColl.hasEvents())
{
//error handlingh
}
Marshaller m = jc.createMarshaller();
m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
m.marshal(jaxbRoot,strWr);
return strWr.toString();
Will using a single instance of JAXBContext and pooling Marshallers help to
resolve this.
I would really appreciate if anyone can recommend how to resolve as we are
forced to recycle our 24/7 application.
Thanks in advance
kesavan