You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Rick Hillegas <ri...@oracle.com> on 2012/03/27 14:25:16 UTC
Garbage-collecting Derby classes, was: Can't remove derby from memory
This discussion is taking place on the user list. It is my understanding
that graceful engine shutdown is supposed to remove references to Derby
classes, making all of the engine code eligible to be garbage-collected.
At least, that is what I thought Lily implemented for 10.8.
In the discussion below, the user is expecting that garbage-collection
will happen after shutting down a single database. I wouldn't expect
that. But it got me to wondering how a user is supposed to shutdown the
engine gracefully via the Derby DataSources. I know how to do this by
passing a shutdown URL to DriverManager, but how do you do this via a
DataSource?
Thanks,
-Rick
-------- Original Message --------
Subject: Re: Can't remove derby from memory
Date: Mon, 26 Mar 2012 18:06:24 -0700
From: Bryan Pendleton <bp...@gmail.com>
Reply-To: Derby Discussion <de...@db.apache.org>
To: Derby Discussion <de...@db.apache.org>
> room. I have noticed that no matter what I do, the ~10MB of memory that is
> taken when the database connect is initiated is held no matter what commands
Certainly sounds like the database isn't getting fully shut down.
> dynamDS.setShutdownDatabase("shutdown");
It's not clear to me that this does anything by itself. The docs say:
If set to the string "shutdown", this will cause the database to shutdown
when a java.sql.Connection object is obtained from the data source. E.g.,
If the data source is an XADataSource, a getXAConnection().getConnection()
is necessary to cause the database to shutdown.
This sounds like you have to get a final connection (and then close it) after
setting ShutdownDatabase.
Did you try getting a connection after calling setShutdownDatabase?
thanks,
bryan
Re: Garbage-collecting Derby classes, was: Can't remove derby from memory
Posted by Knut Anders Hatlen <kn...@oracle.com>.
Rick Hillegas <ri...@oracle.com> writes:
> This discussion is taking place on the user list. It is my
> understanding that graceful engine shutdown is supposed to remove
> references to Derby classes, making all of the engine code eligible to
> be garbage-collected. At least, that is what I thought Lily
> implemented for 10.8.
I believe that shutting down the engine only makes the Derby engine
classes eligible for garbage collection if there are no references to
the classloader in which the engine classes lives. So I think the
classes will only be garbage collected if the driver was loaded in a
separate classloader. (There may also be references to connections,
statements, data sources, or other JDBC objects, in the user code that
prevent gc after shutdown.)
Instances of the engine classes (monitor, caches, etc), on the other
hand, should be eligible for garbage collection after engine shutdown,
even if the engine is not in a separate classloader.
> In the discussion below, the user is expecting that garbage-collection
> will happen after shutting down a single database. I wouldn't expect
> that. But it got me to wondering how a user is supposed to shutdown
> the engine gracefully via the Derby DataSources. I know how to do this
> by passing a shutdown URL to DriverManager, but how do you do this via
> a DataSource?
DataSourceConnector.shutEngine() in the test framework (used for
shutting down the engine on CDC/FP) does this using an empty database
name.
ds.setDatabaseName("");
ds.setShutdownDatabase("shutdown");
Not sure if we have documented this approach.
--
Knut Anders