From 2e0088166c915779cbbaa627fd6614a91faa3d8e Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sat, 13 Apr 2019 09:36:03 -0700 Subject: [PATCH] Move GCMemoryInfo to shared partition Signed-off-by: dotnet-bot --- .../shared/System.Private.CoreLib.Shared.projitems | 1 + .../shared/System/GCMemoryInfo.cs | 56 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/System.Private.CoreLib/shared/System/GCMemoryInfo.cs diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems index cb7fec8..716dc56 100644 --- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems @@ -233,6 +233,7 @@ + diff --git a/src/System.Private.CoreLib/shared/System/GCMemoryInfo.cs b/src/System.Private.CoreLib/shared/System/GCMemoryInfo.cs new file mode 100644 index 0000000..72c2aca --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/GCMemoryInfo.cs @@ -0,0 +1,56 @@ +// 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. + +namespace System +{ + public readonly struct GCMemoryInfo + { + /// + /// High memory load threshold when the last GC occured + /// + public long HighMemoryLoadThresholdBytes { get; } + + /// + /// Memory load when the last GC ocurred + /// + public long MemoryLoadBytes { get; } + + /// + /// 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. + /// + public long TotalAvailableMemoryBytes { get; } + + /// + /// The total heap size when the last GC ocurred + /// + public long HeapSizeBytes { get; } + + /// + /// The total fragmentation when the last GC ocurred + /// + /// Let's take the example below: + /// | OBJ_A | OBJ_B | OBJ_C | OBJ_D | OBJ_E | + /// + /// 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: + /// | OBJ_A | F | OBJ_D | + /// + /// 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 + /// considered part of the FragmentedBytes, and will also be used to allocate new objects + /// + public long FragmentedBytes { get; } + + internal GCMemoryInfo(long highMemoryLoadThresholdBytes, + long memoryLoadBytes, + long totalAvailableMemoryBytes, + long heapSizeBytes, + long fragmentedBytes) + { + HighMemoryLoadThresholdBytes = highMemoryLoadThresholdBytes; + MemoryLoadBytes = memoryLoadBytes; + TotalAvailableMemoryBytes = totalAvailableMemoryBytes; + HeapSizeBytes = heapSizeBytes; + FragmentedBytes = fragmentedBytes; + } + } +} -- 2.7.4