Skip to content

Commit

Permalink
use standard NETCOREAPP3_1_OR_GREATER directive
Browse files Browse the repository at this point in the history
  • Loading branch information
antonfirsov committed Nov 26, 2021
1 parent 9ec8dc7 commit e10126e
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 10 deletions.
4 changes: 0 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,4 @@
<PropertyGroup Condition="$(Configuration.StartsWith('Release')) == true">
<Optimize>true</Optimize>
</PropertyGroup>

<PropertyGroup>
<DefineConstants Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','netcoreapp3.1'))">$(DefineConstants);NETCORE31COMPATIBLE</DefineConstants>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// Port of BCL internal utility:
// https://github.com/dotnet/runtime/blob/57bfe474518ab5b7cfe6bf7424a79ce3af9d6657/src/libraries/System.Private.CoreLib/src/System/Gen2GcCallback.cs
#if NETCORE31COMPATIBLE
#if NETCOREAPP3_1_OR_GREATER
using System;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public UniformUnmanagedMemoryPool(int bufferLength, int capacity, TrimSettings t
if (trimSettings.Enabled)
{
UpdateTimer(trimSettings, this);
#if NETCORE31COMPATIBLE
#if NETCOREAPP3_1_OR_GREATER || NETFRAMEWORK
Gen2GcCallback.Register(s => ((UniformUnmanagedMemoryPool)s).Trim(), this);
#endif
this.lastTrimTimestamp = Stopwatch.ElapsedMilliseconds;
Expand Down Expand Up @@ -328,7 +328,7 @@ private bool TrimLowPressure(UnmanagedMemoryHandle[] buffersLocal)

private bool IsHighMemoryPressure()
{
#if NETCORE31COMPATIBLE
#if NETCOREAPP3_1_OR_GREATER
GCMemoryInfo memoryInfo = GC.GetGCMemoryInfo();
return memoryInfo.MemoryLoadBytes >= memoryInfo.HighMemoryLoadThresholdBytes * this.trimSettings.HighPressureThresholdRate;
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ internal override MemoryGroup<T> AllocateGroup<T>(

private static long GetDefaultMaxPoolSizeBytes()
{
#if NETCORE31COMPATIBLE
#if NETCOREAPP3_1_OR_GREATER
// On 64 bit .NET Core 3.1+, set the pool size to a portion of the total available memory.
// There is a bug in GC.GetGCMemoryInfo() on .NET 5 + 32 bit, making TotalAvailableMemoryBytes unreliable:
// https://github.com/dotnet/runtime/issues/55126#issuecomment-876779327
Expand Down
1 change: 0 additions & 1 deletion tests/ImageSharp.Tests/ImageSharp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<RootNamespace>SixLabors.ImageSharp.Tests</RootNamespace>
<Configurations>Debug;Release;Debug-InnerLoop;Release-InnerLoop</Configurations>
<DefineConstants Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','netcoreapp3.1'))">$(DefineConstants);NETCORE31COMPATIBLE</DefineConstants>
</PropertyGroup>

<Choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static void LeakPoolInstance()
}
}

#if NETCORE31COMPATIBLE
#if NETCOREAPP3_1_OR_GREATER
public static readonly bool Is32BitProcess = !Environment.Is64BitProcess;
private static readonly List<byte[]> PressureArrays = new();

Expand Down

0 comments on commit e10126e

Please sign in to comment.