java - Close connections in pool/cache (cache created with singleton) when Eclipse reloads context -


I am using Eclipse to develop a Java web app and called my IT department and said that I have 75 Open Oracle connections are developing Oracle server from my PC Deployed App is using the same singleton connection bean for one year and I have not had any problems with more connections from there. IT also confirmed that I had only 4 open connections on the deployment server, sometime when I developed locally in Eclipse

Looking at the console debug output, all at the initial startup Something looks good

  September 27, 2010 9:39:08 AM Organizations.Talina. Start. Catalina started == No ConnCache Been example found == About connection cache data start == About loading properties == Using jdbc to start data source: oracle: thin: @hostname : Port: oracle-sid == Attributes File Reading == Setting From Startup Column 3 == Multiplier {TimedTime = 4, Minimalitit = 4, ConnectionWitTimeet = 44, Maximilit = 5, PrimerLimit = 3, Abandoned Connection Timeout = 281, Inactivity Time = 26 9}  

But then I saw Eclipse reloads the reference while following the message SEVERE in the console

  September 27, 2010 9:40:38 AM : Org.apache.catalina.core.StandardContext Reload information: reloading this reference has begun September 27, 2010 9:40:38 AM. Org.apache.catalina.loader.WebappClassLoader Clear ReferencesWebsey Sawer: Web Application [] registered JBDC driver [oracle.jdbc.driver.OracleDriver] but failed to cancel the web application when it was stopped. To prevent memory leakage, the JDBC driver has not been registered forcibly. September 27, 2010 9:40:38 AM Org.apache.catalina.loader.WebappClassLoader explicit referencesFreads SEVERE: The web application [] has started a thread called a thread (thread-9), but it has failed to stop. This is very likely to create a memory leak.  

I think the Eclipse reloads the context each time to recreate a connection cache and the old connection and cache are not being destroyed. When the ability to reload, how can I get Eclipse to end the cash or to stop all previous connections. I can post my connection, if necessary, Baynes Class.

It appears that you are leaking memory through unknown relationships, the previous version of the application It is quite possible if you have chosen to publish automation of your web application from Eclipse to Tomcat.

Tomcat will abandon the web application's current classloader, when it will attempt to reload all the objects from this GC root (classloader), which will still be organized, the garbage will not be collected. Due to the presence of a singleton (I'm assuming that singleton stores a DataSource object or maintains a pool of connections objects), this connection < / Code> Objects will never be considered as accessible objects, and therefore, will not be eligible for GC.

In a short time, you can do the following:

  • If you can help it, restart the tomcat whenever you want to publish a new version of the application is needed.
  • Apply a ServletContextListener , and when trying to cancel the singleton reference, the servlet (app) reference is lost. This creates the singleton object unrecoverable, and therefore GC Is eligible for. Recommended because it is limited to production, until Tommack is restarted.

By the way, this behavior, where the single song contains memory and therefore the connection leak any application server, until the server is restarted from time to time without restarting the server. goes. The only way to prevent this, is to make sure that the singleton is destroyed when the application context is destroyed.


Comments