workaround potencial memory leaks

LSLKeyTest
UbitUmarov 2016-08-22 06:03:39 +01:00
parent 52a80f1742
commit 5d5bad5fc1
3 changed files with 66 additions and 61 deletions

View File

@ -316,8 +316,8 @@ namespace OpenSim.Data.MySQL
return 0; return 0;
} }
MySqlCommand cmd = conn.CreateCommand(); using(MySqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = String.Format("select count(*) as count from {0}",m_Table); cmd.CommandText = String.Format("select count(*) as count from {0}",m_Table);
using (IDataReader reader = cmd.ExecuteReader()) using (IDataReader reader = cmd.ExecuteReader())
@ -327,21 +327,22 @@ namespace OpenSim.Data.MySQL
count = Convert.ToInt32(reader["count"]); count = Convert.ToInt32(reader["count"]);
} }
} }
}
return count; return count;
} }
public bool Delete(string id) public bool Delete(string id)
{ {
MySqlCommand cmd = new MySqlCommand(); using(MySqlCommand cmd = new MySqlCommand())
{
cmd.CommandText = String.Format("delete from {0} where id = ?id",m_Table); cmd.CommandText = String.Format("delete from {0} where id = ?id",m_Table);
cmd.Parameters.AddWithValue("?id", id); cmd.Parameters.AddWithValue("?id", id);
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
}
cmd.Dispose();
return true; return true;
} }

View File

@ -440,7 +440,8 @@ namespace OpenSim.Data.MySQL
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon); using(MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count",dbcon))
{
cmd.Parameters.AddWithValue("?start",start); cmd.Parameters.AddWithValue("?start",start);
cmd.Parameters.AddWithValue("?count", count); cmd.Parameters.AddWithValue("?count", count);
@ -473,6 +474,7 @@ namespace OpenSim.Data.MySQL
m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
} }
} }
}
return retList; return retList;
} }

View File

@ -518,9 +518,10 @@ namespace OpenSim.Data.PGSQL
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
NpgsqlCommand cmd = new NpgsqlCommand( @"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid using(NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid
FROM XAssetsMeta FROM XAssetsMeta
LIMIT :start, :count", dbcon); LIMIT :start, :count",dbcon))
{
cmd.Parameters.Add(m_database.CreateParameter("start",start)); cmd.Parameters.Add(m_database.CreateParameter("start",start));
cmd.Parameters.Add(m_database.CreateParameter("count", count)); cmd.Parameters.Add(m_database.CreateParameter("count", count));
@ -554,6 +555,7 @@ namespace OpenSim.Data.PGSQL
} }
} }
} }
}
return retList; return retList;
} }