tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Shifman <mark.shif...@yale.edu>
Subject JAXBContext leaks memory
Date Mon, 03 May 2010 16:15:43 GMT
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.

The JAXBContext instance is created with a singleton that is an enum (using Josh Block's pattern):

public enum JAXBContextMascot {
	INSTANCE("com.matrixscience.xmlns.schema.mascot_search_results_2" );
	private JAXBContext ctx;
	JAXBContextMascot(String contextPath) {
		try {
			ctx =JAXBContext.newInstance(clazz);
		} catch (JAXBException e) {
			throw new RuntimeException(e);
		}
	}
	public Unmarshaller createUnmarshaller(){
		try {
			return ctx.createUnmarshaller();
		} catch (JAXBException e) {
			throw new RuntimeException(e);
		}
	}
}

Am I doing something wrong which is causing the memory leak?
JAXBContext.newInstance() can take a ClassLoader argument.  Is there some ClassLoader I should
be using that will get around this?

Any help would be appreciated.
mas


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message