KevinQi1981 / memcache-client-forjava

Automatically exported from code.google.com/p/memcache-client-forjava
0 stars 0 forks source link

ClassLoader 内存泄露 #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
现象是Reload Servlet 
Container不能完全释放内存,会存在多个容器为Web
application创建的实例而最终导致OOM,有些线程也不能被销毁,
如下:

pool-2-thread-1 [WAITING] CPU time: 0:00
sun.misc.Unsafe.park(boolean, long)
java.util.concurrent.locks.LockSupport.parkNanos(Object, long)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos
(long)
java.util.concurrent.DelayQueue.take()
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take()
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take()
java.util.concurrent.ThreadPoolExecutor.getTask()
java.util.concurrent.ThreadPoolExecutor$Worker.run()
java.lang.Thread.run()

看代码MemcachedCacheManager的stop()方法没有显式销毁创建的SocketPo
ol,看起来
比较有问题。

Original issue reported on code.google.com by hugo...@gmail.com on 9 Jul 2009 at 3:15

GoogleCodeExporter commented 9 years ago
纠正一下:MemcachedCacheManager.stop()关闭了SocketPool。

profile了一下程序发现问题是出在:CacheUtil里声明的localCache静
态变量,使用的是
DefaultCacheImpl,这个Cache实现类本身是没问题,但这个类会起��
�个维护线程,而CacheUtil
里没有shutdown这个localCache的调用,这个维护线程不会被销毁��
�
1)建议把localCache改成ConcurrentHashMap就可以了;似乎没有必要�
��DefaultCacheImpl;
2)或增加stopLocalCache()方法在CacheUtil里,并在MemcachedCacheManager
的stop()方法里显
示调用CacheUtil.stopLocalCache();

Hugo

Original comment by hugo...@gmail.com on 10 Jul 2009 at 5:24

GoogleCodeExporter commented 9 years ago
应该是如果采用热部署的时候由于无法销毁CacheUtil的线程池��
�致的问题,冷部署不存在问题,不过已经修
复,谢谢你的关注。

Original comment by cenwen...@gmail.com on 10 Jul 2009 at 6:26

GoogleCodeExporter commented 9 years ago

Original comment by cenwen...@gmail.com on 10 Jul 2009 at 6:26