* If a server has statistics, print these out to the log every hour to get some idea of how these evolve
* When returning GC.GetTotalMemory(), force collection first in order to get more accurate figures0.6.0-stable
parent
be400d1bd0
commit
686f16cedd
|
@ -28,6 +28,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Timers;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.Statistics;
|
using OpenSim.Framework.Statistics;
|
||||||
|
@ -41,6 +42,12 @@ namespace OpenSim.Framework.Servers
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This will control a periodic log printout of the current 'show stats' (if they are active) for this
|
||||||
|
/// server.
|
||||||
|
/// </summary>
|
||||||
|
private Timer m_periodicLogStatsTimer = new Timer(60 * 60 * 1000);
|
||||||
|
|
||||||
protected ConsoleBase m_console;
|
protected ConsoleBase m_console;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -68,6 +75,20 @@ namespace OpenSim.Framework.Servers
|
||||||
{
|
{
|
||||||
m_startuptime = DateTime.Now;
|
m_startuptime = DateTime.Now;
|
||||||
m_version = VersionInfo.Version;
|
m_version = VersionInfo.Version;
|
||||||
|
|
||||||
|
m_periodicLogStatsTimer.Elapsed += new ElapsedEventHandler(LogStats);
|
||||||
|
m_periodicLogStatsTimer.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Print statistics to the logfile, if they are active
|
||||||
|
/// </summary>
|
||||||
|
protected void LogStats(object source, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
if (m_stats != null)
|
||||||
|
{
|
||||||
|
m_log.Info(m_stats.Report());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace OpenSim.Framework.Statistics
|
||||||
sb.Append(
|
sb.Append(
|
||||||
string.Format(
|
string.Format(
|
||||||
"Allocated to OpenSim : {0} MB" + Environment.NewLine,
|
"Allocated to OpenSim : {0} MB" + Environment.NewLine,
|
||||||
Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)));
|
Math.Round(GC.GetTotalMemory(true) / 1024.0 / 1024.0)));
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue