mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-23 13:07:07 +01:00
Fix issues with retrieving process memory
This commit is contained in:
@@ -122,7 +122,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
public FifoSemaphore TopicSendSemaphore { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public long MemoryUsage => process.MemoryUsage;
|
||||
public long? MemoryUsage => process.MemoryUsage;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Byond.TopicSender.ITopicClient"/> for the <see cref="SessionController"/>.
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Tgstation.Server.Host.System
|
||||
/// <summary>
|
||||
/// Gets the process' memory usage in bytes.
|
||||
/// </summary>
|
||||
long MemoryUsage { get; }
|
||||
long? MemoryUsage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Set's the owned <see cref="global::System.Diagnostics.Process.PriorityClass"/> to a non-normal value.
|
||||
|
||||
@@ -23,7 +23,21 @@ namespace Tgstation.Server.Host.System
|
||||
public Task<int?> Lifetime { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public long MemoryUsage => handle.VirtualMemorySize64;
|
||||
public long? MemoryUsage
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return handle.VirtualMemorySize64;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "Failed to get PID {pid}'s memory usage!", Id);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IProcessFeatures"/> for the <see cref="Process"/>.
|
||||
|
||||
Reference in New Issue
Block a user