cosmetics

0.9.1.1
UbitUmarov 2019-11-20 23:16:20 +00:00
parent 0cf3ec553a
commit bd12d60e80
5 changed files with 33 additions and 31 deletions

View File

@ -52,21 +52,21 @@ namespace OpenSim.Framework.Monitoring
Math.Round((MemoryWatchdog.LastHeapAllocationRate * 1000) / 1048576.0, 3),
Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1048576.0, 3));
Process myprocess = Process.GetCurrentProcess();
// if (!myprocess.HasExited)
try
{
myprocess.Refresh();
sb.AppendFormat(
"Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
Math.Round(myprocess.WorkingSet64 / 1024.0 / 1024.0),
Math.Round(myprocess.PagedMemorySize64 / 1024.0 / 1024.0),
Math.Round(myprocess.VirtualMemorySize64 / 1024.0 / 1024.0));
sb.AppendFormat(
"Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
Math.Round(myprocess.PeakWorkingSet64 / 1024.0 / 1024.0),
Math.Round(myprocess.PeakPagedMemorySize64 / 1024.0 / 1024.0),
Math.Round(myprocess.PeakVirtualMemorySize64 / 1024.0 / 1024.0));
using (Process myprocess = Process.GetCurrentProcess())
{
sb.AppendFormat(
"Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
Math.Round(myprocess.WorkingSet64 / 1024.0 / 1024.0),
Math.Round(myprocess.PagedMemorySize64 / 1024.0 / 1024.0),
Math.Round(myprocess.VirtualMemorySize64 / 1024.0 / 1024.0));
sb.AppendFormat(
"Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
Math.Round(myprocess.PeakWorkingSet64 / 1024.0 / 1024.0),
Math.Round(myprocess.PeakPagedMemorySize64 / 1024.0 / 1024.0),
Math.Round(myprocess.PeakVirtualMemorySize64 / 1024.0 / 1024.0));
}
}
catch
{ }

View File

@ -435,21 +435,19 @@ Asset service request failures: {3}" + Environment.NewLine,
// Get the amount of physical memory, allocated with the instance of this program, in kilobytes;
// the working set is the set of memory pages currently visible to this program in physical RAM
// memory and includes both shared (e.g. system libraries) and private data
double memUsage = Process.GetCurrentProcess().WorkingSet64 / 1024.0;
// Get the number of threads from the system that are currently
// running
int numberThreadsRunning = 0;
foreach (ProcessThread currentThread in
Process.GetCurrentProcess().Threads)
double memUsage = 0;
using(Process p = Process.GetCurrentProcess())
{
// A known issue with the current process .Threads property is
// that it can return null threads, thus don't count those as
// running threads and prevent the program function from failing
if (currentThread != null &&
currentThread.ThreadState == ThreadState.Running)
memUsage = p.WorkingSet64 / 1024.0;
// Get the number of threads from the system that are currently
// running
foreach (ProcessThread currentThread in p.Threads)
{
numberThreadsRunning++;
if (currentThread != null && currentThread.ThreadState == ThreadState.Running)
numberThreadsRunning++;
}
}

View File

@ -2485,7 +2485,10 @@ namespace OpenSim.Framework
case FireAndForgetMethod.SmartThreadPool:
return m_ThreadPool.MaxThreads - m_ThreadPool.InUseThreads;
case FireAndForgetMethod.Thread:
return MAX_SYSTEM_THREADS - System.Diagnostics.Process.GetCurrentProcess().Threads.Count;
{
using(Process p = System.Diagnostics.Process.GetCurrentProcess())
return MAX_SYSTEM_THREADS - p.Threads.Count;
}
default:
throw new NotImplementedException();
}
@ -2972,7 +2975,8 @@ namespace OpenSim.Framework
public static long GetPhysicalMemUse()
{
return System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
using (Process p = System.Diagnostics.Process.GetCurrentProcess())
return p.WorkingSet64;
}
// returns a timestamp in ms as double

View File

@ -684,7 +684,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if(destinationHandle == sourceRegion.RegionHandle)
{
sp.ControllingClient.SendTeleportFailed("Can't teleport to a region on same map position. Try going other region first, then retry");
sp.ControllingClient.SendTeleportFailed("Can't teleport to a region on same map position. Try going to another region first, then retry from there");
return;
}

View File

@ -3689,7 +3689,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemory");
long pws = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
long pws = Util.GetPhysicalMemUse();
if (pws > Int32.MaxValue)
return Int32.MaxValue;
@ -3703,9 +3703,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemoryKB");
long pws = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
long pws = Util.GetPhysicalMemUse();
if((pws & 0x3FFL) != 0)
if ((pws & 0x3FFL) != 0)
pws += 0x400L;
pws >>= 10;