I have a JAX-RS webservice served using Tomcat 6. I'm using Guice to inject my resources and to create the Servlet.
I've definitely got a memory leak and I assume this is because I'm not handling either the end of the request or the shutdown of the App.
If I continually refresh requests against the service I can see that the memory use of Tomcat climbs and doesn't reduce until I recycle Tomcat.
I've attempted to RTFM but I'm not grokking the lifecycle.
I create the Servlet using
public class RadWebServiceServletConfig extends GuiceServletContextListener {
@Override
protected Injector getInjector() {
return Guice.createInjector(new JerseyServletModule() {
@Override
protected void configureServlets() {
// Must configure at least one JAX-RS resource or the
// server will fail to start.
bind(Crags.class);
bind(IDataFacade.class).to(DataFacade.class);
bind(IRepository.class).to(Repository.class);
//filter all requests to log
filter("/*").through(LoggingFilter.class);
// Route all requests through GuiceContainer
Map<String, String> params = new HashMap<String, String>();
params.put("com.sun.jersey.spi.container.ContainerRequestFilters",
"com.sun.jersey.api.container.filter.GZIPContentEncodingFilter");
params.put("com.sun.jersey.spi.container.ContainerResponseFilters",
"com.sun.jersey.api.container.filter.GZIPContentEncodingFilter");
serve("/*").with(GuiceContainer.class, params);
}
});
}
}
So am I being silly? Where do I catch the end of requests or the app context?