Skip to content

Commit 2e00881

Browse files
committed
Move GCMemoryInfo to shared partition
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
1 parent ce952e7 commit 2e00881

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@
233233
<Compile Include="$(MSBuildThisFileDirectory)System\FlagsAttribute.cs" />
234234
<Compile Include="$(MSBuildThisFileDirectory)System\FormatException.cs" />
235235
<Compile Include="$(MSBuildThisFileDirectory)System\FormattableString.cs" />
236+
<Compile Include="$(MSBuildThisFileDirectory)System\GCMemoryInfo.cs" />
236237
<Compile Include="$(MSBuildThisFileDirectory)System\Gen2GcCallback.cs" />
237238
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\BidiCategory.cs" />
238239
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\Calendar.cs" />
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace System
6+
{
7+
public readonly struct GCMemoryInfo
8+
{
9+
/// <summary>
10+
/// High memory load threshold when the last GC occured
11+
/// </summary>
12+
public long HighMemoryLoadThresholdBytes { get; }
13+
14+
/// <summary>
15+
/// Memory load when the last GC ocurred
16+
/// </summary>
17+
public long MemoryLoadBytes { get; }
18+
19+
/// <summary>
20+
/// Total available memory for the GC to use when the last GC ocurred. By default this is the physical memory on the machine, but it may be customized by specifying a HardLimit.
21+
/// </summary>
22+
public long TotalAvailableMemoryBytes { get; }
23+
24+
/// <summary>
25+
/// The total heap size when the last GC ocurred
26+
/// </summary>
27+
public long HeapSizeBytes { get; }
28+
29+
/// <summary>
30+
/// The total fragmentation when the last GC ocurred
31+
///
32+
/// Let's take the example below:
33+
/// | OBJ_A | OBJ_B | OBJ_C | OBJ_D | OBJ_E |
34+
///
35+
/// Let's say OBJ_B, OBJ_C and and OBJ_E are garbage and get collected, but the heap does not get compacted, the resulting heap will look like the following:
36+
/// | OBJ_A | F | OBJ_D |
37+
///
38+
/// The memory between OBJ_A and OBJ_D marked `F` is considered part of the FragmentedBytes, and will be used to allocate new objects. The memory after OBJ_D will not be
39+
/// considered part of the FragmentedBytes, and will also be used to allocate new objects
40+
/// </summary>
41+
public long FragmentedBytes { get; }
42+
43+
internal GCMemoryInfo(long highMemoryLoadThresholdBytes,
44+
long memoryLoadBytes,
45+
long totalAvailableMemoryBytes,
46+
long heapSizeBytes,
47+
long fragmentedBytes)
48+
{
49+
HighMemoryLoadThresholdBytes = highMemoryLoadThresholdBytes;
50+
MemoryLoadBytes = memoryLoadBytes;
51+
TotalAvailableMemoryBytes = totalAvailableMemoryBytes;
52+
HeapSizeBytes = heapSizeBytes;
53+
FragmentedBytes = fragmentedBytes;
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)