I have a webapp running under Tomcat with Derby embedded inside it, and
after a number of redeploys Tomcat falls over with the dreaded PermGen
space error. I'm running Derby in server mode as I want to be able to
connect to it externally whilst the webapp is running. The webapp has
startup/shutdown hooks to start and stop Derby, but the 'stop' part
obviously isn't working. I'm doing a DriverManager.getConnection() with
shutdown=true, followed by NetworkServerControl.shutdown(). After this
I can't connect to the database (as expected), but jmap shows a load of
Derby objects are still loaded, and jstack shows several instances of this:
"derby.antiGC" daemon prio=1 tid=0x088e7000 nid=0xd in Object.wait()
[0xc64ce000..0xc64ceb60]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0xcaff88f0> (a
org.apache.derby.impl.services.monitor.AntiGC)
at java.lang.Object.wait(Object.java:485)
at org.apache.derby.impl.services.monitor.AntiGC.run(Unknown
Source)
- locked <0xcaff88f0> (a
org.apache.derby.impl.services.monitor.AntiGC)
at java.lang.Thread.run(Thread.java:619)
So it's clear that although the Derby server is stopped, it's still
zombified somewhere inside the Tomcat JVM. How do I cleanly and
completely remove Derby from a running JVM?
--
Alan Burlison
--