我有一个基于Windows 2012的服务器使用wrapper.exe运行Tomcat 8和Java 7实例作为Windows服务。
将我的服务迁移到64位JVM后,我的服务关闭时间比平时要长,早期关机时间约为8-10秒,现在最多可达1分钟。
当我触发进程关闭10秒后,这些线程似乎仍然存在。请让我知道真正触发这一点的原因。
13-Dec-2015 17:12:37.404 INFO [Thread-15] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-7000"]
13-Dec-2015 17:12:37.482 INFO [Thread-15] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-7443"]
13-Dec-2015 17:12:37.545 INFO [Thread-15] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-apr-7009"]
13-Dec-2015 17:12:37.607 INFO [Thread-15] org.apache.catalina.core.StandardService.stopInternal Stopping service Catalina
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [Server: Logger Manager] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:503)
com.MyCom.server.logger.LoggerManager.run(LoggerManager.java:193)
java.lang.Thread.run(Thread.java:745)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [DiskWriteThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
com.MyCom.server.logger.CacheToDiskWriter.run(CacheToDiskWriter.java:62)
java.lang.Thread.run(Thread.java:745)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [LogManagerMonitor thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Thread.sleep(Native Method)
com.MyCom.server.logger.LogManagerMonitor.run(LogManagerMonitor.java:43)
java.lang.Thread.run(Thread.java:745)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [SNMPForwarderHBSendThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
snmp.SNMPForwarderHBSendThread._sleep(SNMPForwarderHBSendThread.java:68)
snmp.SNMPForwarderHBSendThread.run(SNMPForwarderHBSendThread.java:55)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [SNMPForwarderHBDeathClock] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
snmp.SNMPForwarderHBDeathClock._sleep(SNMPForwarderHBDeathClock.java:75)
snmp.SNMPForwarderHBDeathClock.run(SNMPForwarderHBDeathClock.java:62)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [SNMPForwarderReceiveThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.net.DualStackPlainDatagramSocketImpl.socketReceiveOrPeekData(Native Method)
java.net.DualStackPlainDatagramSocketImpl.receive0(DualStackPlainDatagramSocketImpl.java:121)
java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:145)
java.net.DatagramSocket.receive(DatagramSocket.java:786)
snmp.SNMPForwarderReceiveThread.run(SNMPForwarderReceiveThread.java:74)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [SNMPForwarderConnectionEstablisherThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
snmp.SNMPForwarderConnectionEstablisherThread._sleep(SNMPForwarderConnectionEstablisherThread.java:244)
snmp.SNMPForwarderConnectionEstablisherThread.run(SNMPForwarderConnectionEstablisherThread.java:223)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [Log Purge Timer] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:552)
java.util.TimerThread.run(Timer.java:505)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [Server: License Expiration Checker] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Thread.sleep(Native Method)
com.MyCom.server.licensing.VXMLLicenseExpirationChecker.run(VXMLLicenseExpirationChecker.java:71)
java.lang.Thread.run(Thread.java:745)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [Transport-reader-group-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
queue.LinkedMessageQueue.dequeue(LinkedMessageQueue.java:139)
queue.TransportMessageReaderWorker.singlePoll(TransportMessageReaderWorker.java:133)
queue.TransportMessageReaderWorker.run(TransportMessageReaderWorker.java:48)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [nioEventLoopGroup-2-1] but has failed to stop it. This is very likely to create a 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:110)
io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
java.lang.Thread.run(Thread.java:745)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [Global-task-executor-group-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1079)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:807)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [IvrProvider-writer-group-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
queue.LinkedMessageQueue.dequeue(LinkedMessageQueue.java:139)
queue.TransportMessageWriterWorker.singlePoll(TransportMessageWriterWorker.java:96)
queue.TransportMessageWriterWorker.run(TransportMessageWriterWorker.java:53)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:552)
java.util.TimerThread.run(Timer.java:505)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [StatsIntervalThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
statistics.StatsIntervalThread._sleep(StatsIntervalThread.java:95)
statistics.StatsIntervalThread.run(StatsIntervalThread.java:56)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [SNMPStatsThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
statistics.SNMPStatsThread._sleep(SNMPStatsThread.java:54)
statistics.SNMPStatsThread.run(SNMPStatsThread.java:35)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [StatsLoggerThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
statistics.StatsLoggerThread._sleep(StatsLoggerThread.java:48)
statistics.StatsLoggerThread.run(StatsLoggerThread.java:31)
13-Dec-2015 17:12:37.623 WARNING [localhost-startStop-2]
org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [CVP] appears to have started a thread named [LoggerManagerWorker] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
com.MyCom.server.util.BoundedLinkedQueue.poll(BoundedLinkedQueue.java:303)
com.MyCom.server.util.ThreadPool.getTask(ThreadPool.java:737)
com.MyCom.server.util.ThreadPool$Worker.run(ThreadPool.java:773)
java.lang.Thread.run(Thread.java:745)
13-Dec-2015 17:12:37.639 INFO [Thread-15] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-7000"]
13-Dec-2015 17:12:37.639 INFO [Thread-15] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-7443"]
13-Dec-2015 17:12:37.639 INFO [Thread-15] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-apr-7009"]
答案 0 :(得分:0)
我在日志中看到了一些线程池。除非提供创建守护程序线程的工厂,否则它们将默认创建非守护程序线程。在所有非守护程序线程终止之前,JVM不会终止。
所以我的猜测是,JVM由未正确关闭的线程池保持活动状态,而是在GCed和最终确定时剔除它们的线程。
最终确定取决于GC压力。当您更改了堆限制时,可能会降低GC的频率,从而延迟关闭。
当然,这是一个相当长的潜在原因链,所以它只是一个猜测。