java - Netty causing memory leak in tomcat -
i'm using netty 4.0.26.final along tomcat 8 implement embedded tcp server inside web application.
the problem when stop tomcat i'm getting message :
the web application [app] appears have started thread named [nioeventloopgroup-2-1] has failed stop it. create memory leak. stack trace of thread: sun.nio.ch.windowsselectorimpl$subselector.poll0(native method) sun.nio.ch.windowsselectorimpl$subselector.poll(windowsselectorimpl.java:296) sun.nio.ch.windowsselectorimpl$subselector.access$400(windowsselectorimpl.java:278) sun.nio.ch.windowsselectorimpl.doselect(windowsselectorimpl.java:159) sun.nio.ch.selectorimpl.lockanddoselect(selectorimpl.java:87) sun.nio.ch.selectorimpl.select(selectorimpl.java:98) io.netty.channel.nio.nioeventloop.select(nioeventloop.java:622) io.netty.channel.nio.nioeventloop.run(nioeventloop.java:310) io.netty.util.concurrent.singlethreadeventexecutor$2.run(singlethreadeventexecutor.java:111) io.netty.util.concurrent.defaultthreadfactory$defaultrunnabledecorator.run(defaultthreadfactory.java:137)
i've tried using class shutdown threads before closing tomcat i'm still having same problem.
@component public class myappservletcontextlistener implements servletcontextlistener{ @override public void contextinitialized(servletcontextevent arg0) { } @override public void contextdestroyed(servletcontextevent arg0) { trackingdaemon trackingdaemon= (trackingdaemon) applicationcontextprovider.getbean("trackingdaemon"); trackingdaemon.bossgroup.shutdowngracefully(); trackingdaemon.workergroup.shutdowngracefully(); } }
bossgroup , workergroup are:
eventloopgroup bossgroup = new nioeventloopgroup(); eventloopgroup workergroup = new nioeventloopgroup();
any appreciated..
i have had problem netty 4 , tomcat 7 , solved capturing future event shutdowngracefully() , awaiting completion. method below called when closing down application.
private void stopchannel() { log.trace("stopping server socket on port '{}'", port); sendmessageservice.deregistermessagesender(endpointid); try { (channel channel : channels) { if (channel != null) { channel.close(); } } serverchannel.close().sync(); log.trace("server socket on port '{}' stopped.", port); } catch (interruptedexception e) { throw new runtimeexception(e); } { future<?> fc = connectiongroup.shutdowngracefully(); future<?> fw = workergroup.shutdowngracefully(); try { fc.await(); // when shutting down in tomcat waits netty threads die fw.await(); } catch (interruptedexception e) { throw new runtimeexception(e); } log.trace("server workergroup has shutdown on port '{}'", port); }
}
Comments
Post a Comment