On 03/05/2010 18:30, Mark Shifman wrote:
> 
> On 05/03/2010 12:48 PM, Pid wrote:
>> On 03/05/2010 17:15, Mark Shifman wrote:
>>> I have a web app running under tomcat-6.0.26 with 
>>> JreMemoryLeakPreventionListener, java jdk1.6.0_18.
>>>
>>> Using jmap -histo pid, I can watch 
>>> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl, etc increase in number
>>> after running my unmarshal action, followed by undeploy and redeploy.  Find 
>>> Leaks in the manager also finds leaks.

Do you see log messages referring to potential leaks in the catalina.out
log (assuming you're on a unix variant)?

If so, can you post them please?

What does the manager 'find leaks' command report exactly?


>> After a few undeploy/redeploy cycles does the number of
>> WebappClassLoader's also increase?
> 
> Yes it increases 1 for each undeploy/redeploy cycle.

> snip... <

>> Maybe.
>>
>>> JAXBContext.newInstance() can take a ClassLoader argument.  Is there some 
>>> ClassLoader I should be using that will get around this?

OK, so I've looked at JAXBContext (and JAXBContextImpl) and it doesn't
(after quick read through) look like it's storing the classloader
argument anywhere during the newInstance call, which is the usual source
of leaks.

>> Where is the jar with the above code, in a webapp?
> The code above in in the war for the web app in a class in 
> WEB-INF/classes/org/blablabla
> 
> It is called via a class that looks like this:
> 
> public class JAXBMascot {
>       protected static Log log = LogFactory.getLog(JAXBMascot.class);
>       private XMLEventReader reader;
>       private Unmarshaller u = 
> JAXBContextMascot.INSTANCE.createUnmarshaller();

You're setting the XMLEventReader, Unmarshaller & InputStream as
instance field values, rather than completing the parsing in the
getInstance() method?

This looks a bit odd to me, but I don't know what the rest of the
instance does...


p

>       private InputStream jxb_in;
> 
>       public static JAXBMascot getInstance(InputStream in) {
>               JAXBMascot m = new JAXBMascot();
>               try {
>                       m.setJxb_in(in);
>                       
> m.setReader(XMLInputFactory.newInstance().createXMLEventReader(in));
>               } catch (Exception e) {
>                       log.fatal("error getting JAXBMascot instance");
>                       IOUtils.closeQuietly(in);
>                       throw new RuntimeException(e);
>               }
> 
>               return m;
>       }
> ....
> }
> 
> This is also in the webapp in WEB-INF/classes/org/blablabla



Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to