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.
7 public readonly struct GCMemoryInfo
10 /// High memory load threshold when the last GC occured
12 public long HighMemoryLoadThresholdBytes { get; }
15 /// Memory load when the last GC ocurred
17 public long MemoryLoadBytes { get; }
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.
22 public long TotalAvailableMemoryBytes { get; }
25 /// The total heap size when the last GC ocurred
27 public long HeapSizeBytes { get; }
30 /// The total fragmentation when the last GC ocurred
32 /// Let's take the example below:
33 /// | OBJ_A | OBJ_B | OBJ_C | OBJ_D | OBJ_E |
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 |
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
41 public long FragmentedBytes { get; }
43 internal GCMemoryInfo(long highMemoryLoadThresholdBytes
,
45 long totalAvailableMemoryBytes
,
49 HighMemoryLoadThresholdBytes
= highMemoryLoadThresholdBytes
;
50 MemoryLoadBytes
= memoryLoadBytes
;
51 TotalAvailableMemoryBytes
= totalAvailableMemoryBytes
;
52 HeapSizeBytes
= heapSizeBytes
;
53 FragmentedBytes
= fragmentedBytes
;