Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,9 @@ public static void RemoveMemoryPressure(long bytesAllocated) { }
public static void ReRegisterForFinalize(object obj) { }
public static void SuppressFinalize(object obj) { }
public static void WaitForPendingFinalizers() { }
#if netcoreapp11
public static long GetAllocatedBytesForCurrentThread() { return default(long); }
#endif
}
public enum GCCollectionMode
{
Expand Down
1 change: 1 addition & 0 deletions src/System.Runtime/tests/System.Runtime.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp1.1'">
<Compile Include="System\ArrayTests.netcoreapp1.1.cs" />
<Compile Include="System\EnumTests.netcoreapp1.1.cs" />
<Compile Include="System\GCTests.netcoreapp1.1.cs" />
<Compile Include="System\IntPtrTests.netcoreapp1.1.cs" />
<Compile Include="System\LazyTests.netcoreapp1.1.cs" />
<Compile Include="System\Runtime\CompilerServices\RuntimeHelpersTests.netcoreapp1.1.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/System.Runtime/tests/System/GCTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace System.Tests
{
public static class GCTests
public static partial class GCTests
{
private static bool s_is32Bits = IntPtr.Size == 4; // Skip IntPtr tests on 32-bit platforms

Expand Down
27 changes: 27 additions & 0 deletions src/System.Runtime/tests/System/GCTests.netcoreapp1.1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using Xunit;

namespace System.Tests
{
public static partial class GCTests
{
[Theory]
[InlineData(1000)]
[InlineData(100000)]
public static void GetAllocatedBytesForCurrentThread(int size)
{
long start = GC.GetAllocatedBytesForCurrentThread();

GC.KeepAlive(new String('a', size));

long end = GC.GetAllocatedBytesForCurrentThread();

Assert.True((end - start) > size, $"Allocated too little: start: {start} end: {end} size: {size}");
Assert.True((end - start) < 5 * size, $"Allocated too much: start: {start} end: {end} size: {size}");
}
}
}