Skip to content

Commit

Permalink
fix: Removed leak warnings when CLR is shutting down or appdomain is …
Browse files Browse the repository at this point in the history
…being unloaded
  • Loading branch information
TwoTenPvP committed Sep 10, 2019
1 parent 16f48c3 commit 48ab3d3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Ruffles/Memory/HeapMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ public void EnsureSize(uint size)
~HeapMemory()
{
try
{
if (!isDead)
{
if (Logging.CurrentLogLevel <= LogLevel.Warning) Logging.LogWarning("Memory was just leaked from the MemoryManager [Size=" + Buffer.Length + "]");
}
else
{
// If shutdown of the CLR has started, or the application domain is being unloaded. We don't want to print leak warnings. As these are legitimate deallocs and not leaks.
if (!Environment.HasShutdownStarted)
{
if (Logging.CurrentLogLevel <= LogLevel.Debug) Logging.LogWarning("Dead memory was just leaked from the MemoryManager [Size=" + _buffer.Length + "]");

if (!isDead)
{
if (Logging.CurrentLogLevel <= LogLevel.Warning) Logging.LogWarning("Memory was just leaked from the MemoryManager [Size=" + Buffer.Length + "]");
}
else
{
if (Logging.CurrentLogLevel <= LogLevel.Debug) Logging.LogWarning("Dead memory was just leaked from the MemoryManager [Size=" + _buffer.Length + "]");
}
}
}
catch
Expand Down

0 comments on commit 48ab3d3

Please sign in to comment.