mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Fixed memory counter not refreshing over time
This commit is contained in:
@@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Services
|
||||
{
|
||||
public class StatsService : IStatsService, IReadyExecutor, INService
|
||||
public class StatsService : IStatsService, IReadyExecutor, INService, IDisposable
|
||||
{
|
||||
private readonly Process _currentProcess = Process.GetCurrentProcess();
|
||||
private readonly DiscordSocketClient _client;
|
||||
@@ -23,8 +23,6 @@ namespace NadekoBot.Services
|
||||
public const string BotVersion = "3.0.7";
|
||||
public string Author => "Kwoth#2452";
|
||||
public string Library => "Discord.Net";
|
||||
|
||||
public double PrivateMemory => _currentProcess.PrivateMemorySize64 / (double)1.MiB();
|
||||
public double MessagesPerSecond => MessageCounter / GetUptime().TotalSeconds;
|
||||
|
||||
private long _textChannels;
|
||||
@@ -173,5 +171,17 @@ namespace NadekoBot.Services
|
||||
_voiceChannels = guilds.Sum(g => g.Channels.Count(cx => cx is IVoiceChannel));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public double GetPrivateMemory()
|
||||
{
|
||||
_currentProcess.Refresh();
|
||||
return _currentProcess.PrivateMemorySize64 / (double)1.MiB();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_currentProcess.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user