Re: Database object was finalized and is initialized
Tobias Downer <[email protected]> Wed, 02 Mar 2005 15:05:47 -0800
| Newsgroups | gmane.comp.db.mckoi |
|---|---|
| Message-ID | <[email protected]> |
Hi Chris,
This message is displayed when the com.mckoi.database.Database object is
finalized by the garbage collector in an initialized state. In itself,
it doesn't indicate a serious problem, but it may cause objects to be
retained in memory (such as the thread handler) with no way of releasing
the resources.
From the code fragment, it appears that a reference to a DBSystem
object is not created. Your code should look something like the following;
DefaultDBConfig dbConfig = new DefaultDBConfig();
dbConfig.setDatabasePath(existingDataSetPath.getAbsolutePath());
dbConfig.setLogPath(existingDbLogPath.getAbsolutePath());
DBSystem session = null;
DBController dbController = DBController.getDefault();
if (dbController.databaseExists(dbConfig) == false)
{
session = dbController.startDatabase(dbConfig));
}
Then when the database is closed, the code is;
session.close();
If the initial code creates and retains a reference to 'session' then
the message won't be displayed and the Database object won't be
finalized until the session is completed.
Hope that helps,
Toby.
Chris Brown wrote:
> Hi,
>
> I'm sometimes see the following message written to System.out or
> System.err:
>
> Database object was finalized and is initialized
>
> I don't know exactly what's causing it though. My application just opens
> and closes the database at this stage (running it in embedded mode), I
> haven't got round to performing any queries (other than CREATE TABLE...).
>
> Here's the code fragment that starts the database:
>
> DefaultDBConfig dbConfig = new DefaultDBConfig();
> dbConfig.setDatabasePath(existingDataSetPath.getAbsolutePath());
> dbConfig.setLogPath(existingDbLogPath.getAbsolutePath());
>
> DBController dbController = DBController.getDefault();
> if (dbController.databaseExists(dbConfig) == false)
> {
> dbController.startDatabase(dbConfig));
> }
>
> I just call close() on the session to shutdown the database.
>
> Any ideas ?
> Thanks,
> Chris
---------------------------------------------------------------
Mckoi SQL Database mailing list http://www.mckoi.com/database/
To unsubscribe, send a message to [email protected]