2016-10-19 4 views
1

私はc3p0接続マネージャを閉じるためにこれらのコードを持っています。メモリリークの原因となるスレッドが存在することを示すメッセージは表示されません。しかし、私のアプリケーションを再デプロイすると、perm gen memoryが増え続けます。tomcatパームスペースを再デプロイ

Oct 19, 2016 11:05:48 AM org.springframework.context.support.AbstractApplicationContext doClose 
INFO: Closing WebApplicationContext for namespace 'dispatcherServlet-servlet': startup date [Wed Oct 19 10:41:03 PHT 2016]; parent: Root WebApplicationContext 
2016-10-19 11:05:48 - [INFO ] CRMContextListener - Trying to Close 
2016-10-19 11:05:53 - [INFO ] CRMContextListener - Close Success 
Oct 19, 2016 11:05:53 AM org.springframework.context.support.AbstractApplicationContext doClose 
INFO: Closing Root WebApplicationContext: startup date [Wed Oct 19 10:40:53 PHT 2016]; root of context hierarchy 
Oct 19, 2016 11:05:53 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc 
SEVERE: A web application registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 
Oct 19, 2016 11:06:03 AM org.apache.catalina.core.StandardContext stop 
INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/crmdev] has not been started 
Oct 19, 2016 11:06:04 AM org.apache.catalina.startup.HostConfig checkResources 
INFO: Undeploying context [/crmdev] 

これは私のサーブレットリスナー

public void contextDestroyed(ServletContextEvent sce) { 
    logger.info("Trying to Close"); 

    for (Object o : C3P0Registry.getPooledDataSources()) { 
     try { 
      ((PooledDataSource) o).close(); 
     } catch (Exception e) { 
      logger.info("No thread was open..."); 
     } 
    } 

    logger.info("Close Success"); 
} 

そして、ここでのコードでは、C3P0

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> 
    <property name="driverClass" value="oracle.jdbc.driver.OracleDriver" /> 
    <property name="jdbcUrl" value="jdbc:oracle:thin:@sph-pdc-vm 1042:1521:DEV" /> 
    <property name="user" value="TSW" /> 
    <property name="password" value="TSW2015#" /> 
    <property name="minPoolSize" value="2" /> 
    <property name="maxPoolSize" value="20" /> 
    <property name="initialPoolSize" value="5" /> 
    <property name="testConnectionOnCheckin" value="true" /> 
    <property name="idleConnectionTestPeriod" value="100" /> 
    <property name="maxIdleTimeExcessConnections" value="5" /> 
    <property name="maxStatementsPerConnection" value="10" /> 
    <property name="acquireIncrement" value="1" /> 
    <property name="statementCacheNumDeferredCloseThreads" value="1" /> 
    <property name="acquireRetryAttempts" value="2" /> 
    <property name="acquireRetryDelay" value="2000" /> 
</bean> 
+0

あなたのプールされた接続は、ヒープではなくPermGenスペースに格納されています。 PermGenは、接続プールのリークが原因ではなく、アプリケーションをTomcatに再デプロイしているために排除されます。 – SimY4

+0

permgenを増加させるのは正常ですか? –

+1

私は開発中にPermGenを増やしたいと思うかもしれません。なぜなら、あなたが開発している間に、たくさんの再展開を行うからです。しかし、生産では、巨大なPermGenは必要ではありません。 – SimY4

答えて

1

のための私の設定では、私はお勧めリークを追跡する場合は、持っていることですthis blog post of mineをご覧ください。

あなただけの問題を取り除くためにしたい場合は、アプリケーションに私のClassLoader Leak Prevention libraryを追加します。

私はあなたが漏れるのこれらの種類を引き起こすことknownでのOracle JDBCドライバを使用することに注意してください。また、あなたのアプリ(WEB-INF/lib)またはTomcatにドライバを保存しますか?

+0

私は自分のojdbcを(WEB-INF/lib) –

+0

にしておいて、それをあなたのアプリケーションの外に移動するか、 'contextDestroyed()' –

+0

'の 'DriverManager'からドライバを明示的に登録解除する必要があります。列挙 drivers = DriverManager.getDrivers ); \tため(; drivers.hasMoreElements()){ \t \tドライバドライバ= drivers.nextElement()。 \t //我々は(driver.getClass()。のgetClassLoader()== this.getClass()。のgetClassLoader()){ \t \t \t試し{ \t場合は、このWebアプリケーション \t \tによってロードされたドライバを検索\t \t \t DriverManager.deregisterDriver(ドライバ); \t \t \t \t logger.info( "成功閉会ドライバー"); \t \t \t}キャッチ(のSQLException E){ \t \t \t \t e.printStackTrace(); \t \t \t} \t \t} \t}」 –

関連する問題