Browse Source

Fix concurrency problem with MemoryAllocatorValidator

pull/3028/head
Socolin 10 months ago
parent
commit
15d11515b7
  1. 12
      tests/ImageSharp.Tests/MemoryAllocatorValidator.cs

12
tests/ImageSharp.Tests/MemoryAllocatorValidator.cs

@ -22,7 +22,10 @@ public static class MemoryAllocatorValidator
TestMemoryDiagnostics backing = LocalInstance.Value; TestMemoryDiagnostics backing = LocalInstance.Value;
if (backing != null) if (backing != null)
{ {
backing.TotalRemainingAllocated--; lock (backing)
{
backing.TotalRemainingAllocated--;
}
} }
} }
@ -31,8 +34,11 @@ public static class MemoryAllocatorValidator
TestMemoryDiagnostics backing = LocalInstance.Value; TestMemoryDiagnostics backing = LocalInstance.Value;
if (backing != null) if (backing != null)
{ {
backing.TotalAllocated++; lock (backing)
backing.TotalRemainingAllocated++; {
backing.TotalAllocated++;
backing.TotalRemainingAllocated++;
}
} }
} }

Loading…
Cancel
Save