diff options
Diffstat (limited to 'OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs')
-rw-r--r-- | OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs index 88a0297..c41c4b9 100644 --- a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs | |||
@@ -435,21 +435,19 @@ Asset service request failures: {3}" + Environment.NewLine, | |||
435 | // Get the amount of physical memory, allocated with the instance of this program, in kilobytes; | 435 | // Get the amount of physical memory, allocated with the instance of this program, in kilobytes; |
436 | // the working set is the set of memory pages currently visible to this program in physical RAM | 436 | // the working set is the set of memory pages currently visible to this program in physical RAM |
437 | // memory and includes both shared (e.g. system libraries) and private data | 437 | // memory and includes both shared (e.g. system libraries) and private data |
438 | double memUsage = Process.GetCurrentProcess().WorkingSet64 / 1024.0; | ||
439 | |||
440 | // Get the number of threads from the system that are currently | ||
441 | // running | ||
442 | int numberThreadsRunning = 0; | 438 | int numberThreadsRunning = 0; |
443 | foreach (ProcessThread currentThread in | 439 | double memUsage = 0; |
444 | Process.GetCurrentProcess().Threads) | 440 | using(Process p = Process.GetCurrentProcess()) |
445 | { | 441 | { |
446 | // A known issue with the current process .Threads property is | 442 | memUsage = p.WorkingSet64 / 1024.0; |
447 | // that it can return null threads, thus don't count those as | 443 | |
448 | // running threads and prevent the program function from failing | 444 | // Get the number of threads from the system that are currently |
449 | if (currentThread != null && | 445 | // running |
450 | currentThread.ThreadState == ThreadState.Running) | 446 | |
447 | foreach (ProcessThread currentThread in p.Threads) | ||
451 | { | 448 | { |
452 | numberThreadsRunning++; | 449 | if (currentThread != null && currentThread.ThreadState == ThreadState.Running) |
450 | numberThreadsRunning++; | ||
453 | } | 451 | } |
454 | } | 452 | } |
455 | 453 | ||