Fixed memory leaks in DBConnection

main
Inga 🏳‍🌈 15 years ago
parent 4520faa013
commit b32340e07c
  1. 6
      MySQLConnector/Connection.cs
  2. 3
      MySQLConnector/Transaction.cs

@ -306,6 +306,12 @@ namespace FLocal.MySQLConnector {
}
}
internal void RemoveTransaction(Transaction transaction) {
lock(this) {
this.transactions.Remove(transaction);
}
}
public void Dispose() {
lock(this) {
foreach(Transaction transaction in this.transactions) {

@ -8,6 +8,7 @@ using System.Data.Common;
namespace FLocal.MySQLConnector {
class Transaction : Core.DB.Transaction {
internal Connection connection;
internal DbConnection sqlconnection;
internal DbTransaction sqltransaction;
@ -17,6 +18,7 @@ namespace FLocal.MySQLConnector {
}
public Transaction(Connection connection, System.Data.IsolationLevel iso) : base() {
this.connection = connection;
this.sqlconnection = connection.createConnection();
try {
if(connection.traits.supportsIsolationLevel()) {
@ -50,6 +52,7 @@ namespace FLocal.MySQLConnector {
this.sqlconnection.Close();
this.sqlconnection.Dispose();
this.finalizedImpl = true;
this.connection.RemoveTransaction(this);
}
}

Loading…
Cancel
Save