set gc memory high pressure to 50% of total memory (sadly it may decide to ignore); change show stats memory report; let robust also show memory on show stats

This commit is contained in:
UbitUmarov
2024-04-04 17:45:38 +01:00
parent f51f81d53f
commit d00dbe11c0
5 changed files with 68 additions and 24 deletions

View File

@@ -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();
}

View File

@@ -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<string> GetCategoryStatsReports(

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -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
}
}