Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The "Detach" is not called in the Dispose of connection [DNET487] #473

Closed
firebird-automations opened this issue Feb 23, 2013 · 4 comments
Closed

Comments

@firebird-automations
Copy link

Submitted by: Hélio Tibagí de Oliveira (chogoki)

The method "isc_detach_database" is not being called in dispose of connections. This makes the process of Firebird (classic mode) is loaded into memory and is only released when the application terminates. Unfortunately we use the old Firebird 1.5, but probably this problem should occur in all versions.

Below is a snippet of code to bypass this problem:

using (var conn = new FbConnection("User=SYSDBA;Password=masterkey;Database=myserver:mydatabase.fdb;Dialect=3;Charset=WIN1252;"))
{
conn.Open();
DataTable dt = new DataTable();
new FbDataAdapter("SELECT FIRST 400 * FROM TABLE", conn).Fill(dt);

           //Hack by reflection to FIX the close/dispose issue
            var fbConnectionInternal = typeof\(FbConnection\)\.GetField\("innerConnection", BindingFlags\.NonPublic \| BindingFlags\.Instance\);
            var innerConnection = fbConnectionInternal\.GetValue\(conn\);
            var iDatabase = innerConnection\.GetType\(\)\.GetField\("db", BindingFlags\.NonPublic \| BindingFlags\.Instance\);
            var db = iDatabase\.GetValue\(innerConnection\);
            var detachMethod = db\.GetType\(\)\.GetMethod\("Detach"\);
            detachMethod\.Invoke\(db, null\);

            conn\.Close\(\);

}

Please can you fix this problem? Many problems are occurring in our servers because of this. Thanks in advance.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

That's very likely because you didn't turned off the connection pooling (at least not in the example above). Add into your connection string "Pooling=False" and see the difference.

@firebird-automations
Copy link
Author

Commented by: Hélio Tibagí de Oliveira (chogoki)

Thanks a lot, you saved my day.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Closing. Not a bug.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Closed [ 6 ]

resolution: Won't Fix [ 2 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants