diff --git a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs index 0d2c5caf80..809a705d4e 100644 --- a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs @@ -46,39 +46,36 @@ namespace OpenSim.Framework.Monitoring public virtual string Report() { StringBuilder sb = new StringBuilder(Environment.NewLine); - sb.Append("MEMORY STATISTICS"); - sb.Append(Environment.NewLine); sb.AppendFormat( - "Heap allocated to OpenSim : {0} MB\n", - Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)); - - sb.AppendFormat( - "Heap allocation rate (last/avg): {0}/{1}MB/s\n", + "Heap allocated: {0}MB \t allocation rate (last/avg): {1}/{2}MB/s\n", + Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0), Math.Round((MemoryWatchdog.LastHeapAllocationRate * 1000) / 1048576.0, 3), Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1048576.0, 3)); + GCMemoryInfo gcmem = GC.GetGCMemoryInfo(); + sb.AppendFormat( + "GCTotalCommited: {0}MB \t GCTotalAvaiable {1}MB \t GCHMthreshold {2}MB\n", + Math.Round(gcmem.TotalCommittedBytes / 1024.0 / 1024.0), + Math.Round(gcmem.TotalAvailableMemoryBytes / 1024.0 / 1024.0), + Math.Round(gcmem.HighMemoryLoadThresholdBytes / 1024.0 / 1024.0)); + try { using (Process myprocess = Process.GetCurrentProcess()) { sb.AppendFormat( - "Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", + "Process memory: Physical {0}MB \t Paged {1}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)); + Math.Round(myprocess.PagedMemorySize64 / 1024.0 / 1024.0)); sb.AppendFormat( - "Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", + "Peak process memory: Physical {0}MB \t Paged {1}MB \t\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)); + Math.Round(myprocess.PeakPagedMemorySize64 / 1024.0 / 1024.0)); sb.AppendFormat("\nTotal process Threads {0}\n", myprocess.Threads.Count); } } catch { } -// else -// sb.Append("Process reported as Exited \n"); - return sb.ToString(); } diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 0e5626b164..2992057b80 100755 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -188,6 +188,43 @@ namespace OpenSim.Framework.Monitoring { foreach (string report in GetAllStatsReports()) con.Output(report); + con.Output(MemoryReport()); + } + + private static string MemoryReport() + { + StringBuilder sb = new StringBuilder(Environment.NewLine); + sb.AppendFormat( + "Heap allocated: {0}MB \t allocation rate (last/avg): {1}/{2}MB/s\n", + Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0), + Math.Round((MemoryWatchdog.LastHeapAllocationRate * 1000) / 1048576.0, 3), + Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1048576.0, 3)); + + GCMemoryInfo gcmem = GC.GetGCMemoryInfo(); + sb.AppendFormat( + "GCTotalCommited: {0}MB \t GCTotalAvaiable {1}MB \t GCHMthreshold {2}MB\n", + Math.Round(gcmem.TotalCommittedBytes / 1024.0 / 1024.0), + Math.Round(gcmem.TotalAvailableMemoryBytes / 1024.0 / 1024.0), + Math.Round(gcmem.HighMemoryLoadThresholdBytes / 1024.0 / 1024.0)); + + try + { + using (Process myprocess = Process.GetCurrentProcess()) + { + sb.AppendFormat( + "Process memory: Physical {0}MB \t Paged {1}MB\n", + Math.Round(myprocess.WorkingSet64 / 1024.0 / 1024.0), + Math.Round(myprocess.PagedMemorySize64 / 1024.0 / 1024.0)); + sb.AppendFormat( + "Peak process memory: Physical {0}MB \t Paged {1}MB \t\n", + Math.Round(myprocess.PeakWorkingSet64 / 1024.0 / 1024.0), + Math.Round(myprocess.PeakPagedMemorySize64 / 1024.0 / 1024.0)); + sb.AppendFormat("\nTotal process Threads {0}\n", myprocess.Threads.Count); + } + } + catch + { } + return sb.ToString(); } private static List GetCategoryStatsReports( diff --git a/OpenSim/Region/Application/runtimeconfig.template.json b/OpenSim/Region/Application/runtimeconfig.template.json index 5ca3137acd..772fa6058f 100644 --- a/OpenSim/Region/Application/runtimeconfig.template.json +++ b/OpenSim/Region/Application/runtimeconfig.template.json @@ -1,7 +1,11 @@ { - "configProperties": { - "System.GC.Server": false, - "System.Drawing.EnableUnixSupport": true, - "System.Globalization.UseNls": true, + "configProperties": { + "System.GC.Server": false, + "System.GC.HighMemoryPercent": 50, + "System.Drawing.EnableUnixSupport": true, + "System.Globalization.UseNls": true, + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false, + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true, + "System.Runtime.TieredCompilation.QuickJit": false } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index adb107320b..416e6babef 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1234,7 +1234,9 @@ namespace OpenSim.Region.Framework.Scenes } */ scriptedcontrols.Clear(); + // gc gets confused with this cycling ControllingClient = null; + GodController = null; // gc gets confused with this cycling } } diff --git a/OpenSim/Server/runtimeconfig.template.json b/OpenSim/Server/runtimeconfig.template.json index c95ce9e516..6d427663d0 100644 --- a/OpenSim/Server/runtimeconfig.template.json +++ b/OpenSim/Server/runtimeconfig.template.json @@ -1,7 +1,11 @@ { - "configProperties": { - "System.GC.Server": false, - "System.Drawing.EnableUnixSupport": true, - "System.Globalization.UseNls": true + "configProperties": { + "System.GC.Server": false, + "System.GC.HighMemoryPercent": 50, + "System.Drawing.EnableUnixSupport": true, + "System.Globalization.UseNls": true, + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false, + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true, + "System.Runtime.TieredCompilation.QuickJit": false } } \ No newline at end of file