From 5d5bad5fc18177d0e1369cc8127f2a1fc4323197 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 Aug 2016 06:03:39 +0100 Subject: workaround potencial memory leaks --- OpenSim/Data/MySQL/MySQLXAssetData.cs | 48 ++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLXAssetData.cs') diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 68e1a5a..ec2bcc6 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -440,37 +440,39 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - 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("?count", count); - - try + using(MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count",dbcon)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader()) + cmd.Parameters.AddWithValue("?start",start); + cmd.Parameters.AddWithValue("?count", count); + + try { - while (dbReader.Read()) + using (MySqlDataReader dbReader = cmd.ExecuteReader()) { - AssetMetadata metadata = new AssetMetadata(); - metadata.Name = (string)dbReader["Name"]; - metadata.Description = (string)dbReader["Description"]; - metadata.Type = (sbyte)dbReader["AssetType"]; - metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. - metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); - metadata.FullID = DBGuid.FromDB(dbReader["ID"]); - metadata.CreatorID = dbReader["CreatorID"].ToString(); + while (dbReader.Read()) + { + AssetMetadata metadata = new AssetMetadata(); + metadata.Name = (string)dbReader["Name"]; + metadata.Description = (string)dbReader["Description"]; + metadata.Type = (sbyte)dbReader["AssetType"]; + metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. + metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); + metadata.FullID = DBGuid.FromDB(dbReader["ID"]); + metadata.CreatorID = dbReader["CreatorID"].ToString(); - // We'll ignore this for now - it appears unused! -// metadata.SHA1 = dbReader["hash"]); + // We'll ignore this for now - it appears unused! + // metadata.SHA1 = dbReader["hash"]); - UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); + UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); - retList.Add(metadata); + retList.Add(metadata); + } } } - } - catch (Exception e) - { - m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); + catch (Exception e) + { + m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); + } } } -- cgit v1.1