change ODEs topcolliders code ( still bad), plus a few memory leaks

LSLKeyTest
UbitUmarov 2016-08-22 20:28:15 +01:00
parent a2c80b20d7
commit 133fce98e7
5 changed files with 34 additions and 40 deletions

View File

@ -97,9 +97,8 @@ namespace OpenSim.Region.UserStatistics
sdr.Read();
totalregions = Convert.ToInt32(sdr["regcnt"]);
}
sdr.Close();
sdr.Dispose();
cmd.Dispose();
sql =
"select client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by client_version order by count(*) desc LIMIT 10;";
@ -120,7 +119,7 @@ namespace OpenSim.Region.UserStatistics
}
}
sdr.Close();
sdr.Dispose();
cmd.Dispose();
if (totalregions > 1)
{
@ -143,11 +142,8 @@ namespace OpenSim.Region.UserStatistics
}
}
sdr.Close();
sdr.Dispose();
cmd.Dispose();
}
}
foreach (ClientVersionData cvd in cliRegData)
@ -163,9 +159,6 @@ namespace OpenSim.Region.UserStatistics
{
regionTotals.Add(cvd.region_id, cvd.count);
}
}
modeldata["ClientData"] = clidata;

View File

@ -227,7 +227,10 @@ TD.align_top { vertical-align: top; }
returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]);
}
sdr.Close();
cmd.Dispose();
}
return returnstruct;
}

View File

@ -145,8 +145,7 @@ namespace OpenSim.Region.UserStatistics
}
}
sdr.Close();
sdr.Dispose();
cmd.Dispose();
}
modeldata["SessionData"] = lstSessions;
return modeldata;

View File

@ -3452,6 +3452,11 @@ namespace OpenSim.Region.PhysicsModule.ODE
}
}
private int compareByCollisionsDesc(OdePrim A, OdePrim B)
{
return -A.CollisionScore.CompareTo(B.CollisionScore);
}
public override Dictionary<uint, float> GetTopColliders()
{
Dictionary<uint, float> topColliders;
@ -3459,7 +3464,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
lock (_prims)
{
List<OdePrim> orderedPrims = new List<OdePrim>(_prims);
orderedPrims.OrderByDescending(p => p.CollisionScore);
orderedPrims.Sort(compareByCollisionsDesc);
topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore);
foreach (OdePrim p in _prims)

View File

@ -30,6 +30,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
@ -803,14 +804,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
return;
}
// update actors collision score
if (p1.CollisionScore >= float.MaxValue - count)
p1.CollisionScore = 0;
p1.CollisionScore += count;
if (p2.CollisionScore >= float.MaxValue - count)
p2.CollisionScore = 0;
p2.CollisionScore += count;
// get first contact
d.ContactGeom curContact = new d.ContactGeom();
@ -1056,6 +1049,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
uint obj2LocalID = 0;
// update actors collision score
if (p1.CollisionScore < float.MaxValue)
p1.CollisionScore += 1.0f;
if (p2.CollisionScore < float.MaxValue)
p2.CollisionScore += 1.0f;
bool p1events = p1.SubscribedEvents();
bool p2events = p2.SubscribedEvents();
@ -2569,27 +2568,22 @@ namespace OpenSim.Region.PhysicsModule.ubOde
}
}
private int compareByCollisionsDesc(OdePrim A, OdePrim B)
{
return -A.CollisionScore.CompareTo(B.CollisionScore);
}
public override Dictionary<uint, float> GetTopColliders()
{
Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
int cnt = 0;
lock (_prims)
{
foreach (OdePrim prm in _prims.Values)
{
if (prm.CollisionScore > 0)
{
returncolliders.Add(prm.LocalID, prm.CollisionScore);
cnt++;
prm.CollisionScore = 0f;
if (cnt > 25)
{
break;
}
}
}
}
return returncolliders;
Dictionary<uint, float> topColliders;
List<OdePrim> orderedPrims;
lock (_activeprims)
orderedPrims = new List<OdePrim>(_activeprims);
orderedPrims.Sort(compareByCollisionsDesc);
topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore);
return topColliders;
}
public override bool SupportsRayCast()