Class MemorySnapshot
- Namespace
- PopcorningGuineaPig.Engine.Diagnostics
- Assembly
- PopcorningGuineaPig.Engine.dll
A point-in-time view of memory usage across categories. Designed to be cheap to construct (small allocations only) and trivially serializable via System.Text.Json.
public sealed record MemorySnapshot : IEquatable<MemorySnapshot>
- Inheritance
-
MemorySnapshot
- Implements
- Inherited Members
Constructors
MemorySnapshot(DateTime, IReadOnlyDictionary<MemoryCategory, long>, int, int, int, long, string, IReadOnlyDictionary<string, long>?, IReadOnlyDictionary<string, AssetCounts>?)
A point-in-time view of memory usage across categories. Designed to be cheap to construct (small allocations only) and trivially serializable via System.Text.Json.
public MemorySnapshot(DateTime CapturedAtUtc, IReadOnlyDictionary<MemoryCategory, long> BytesByCategory, int Gen0Collections, int Gen1Collections, int Gen2Collections, long TotalAllocatedBytesSinceStart, string Description, IReadOnlyDictionary<string, long>? TextureBytesByScene = null, IReadOnlyDictionary<string, AssetCounts>? AssetCountsByScene = null)
Parameters
CapturedAtUtcDateTimeUTC timestamp the snapshot was assembled. Sampled before the data reads so it is never later than the data it describes.
BytesByCategoryIReadOnlyDictionary<MemoryCategory, long>Bytes attributed to each MemoryCategory. Every enum value is present; absent values would be a bug.
Gen0CollectionsintNumber of Gen0 garbage collections since process start (
GC.CollectionCount(0)).Gen1CollectionsintNumber of Gen1 garbage collections since process start.
Gen2CollectionsintNumber of Gen2 garbage collections since process start.
TotalAllocatedBytesSinceStartlongCumulative allocations since process start (
GC.GetTotalAllocatedBytes(precise: false)).DescriptionstringFree-form label for the snapshot (e.g., scenario name or user-supplied tag).
TextureBytesBySceneIReadOnlyDictionary<string, long>Texture bytes grouped by scene tag (Story 12.3 Task 1). Empty-string key holds untagged assets. May be empty when no scene-aware capture is available.
AssetCountsBySceneIReadOnlyDictionary<string, AssetCounts>Asset counts grouped by scene tag (Story 12.3 Task 1). Empty-string key holds untagged assets.
Properties
AssetCountsByScene
Asset counts grouped by scene tag (Story 12.3 Task 1). Empty-string key holds untagged assets.
public IReadOnlyDictionary<string, AssetCounts>? AssetCountsByScene { get; init; }
Property Value
BytesByCategory
Bytes attributed to each MemoryCategory. Every enum value is present; absent values would be a bug.
public IReadOnlyDictionary<MemoryCategory, long> BytesByCategory { get; init; }
Property Value
CapturedAtUtc
UTC timestamp the snapshot was assembled. Sampled before the data reads so it is never later than the data it describes.
public DateTime CapturedAtUtc { get; init; }
Property Value
Description
Free-form label for the snapshot (e.g., scenario name or user-supplied tag).
public string Description { get; init; }
Property Value
Gen0Collections
Number of Gen0 garbage collections since process start (GC.CollectionCount(0)).
public int Gen0Collections { get; init; }
Property Value
Gen1Collections
Number of Gen1 garbage collections since process start.
public int Gen1Collections { get; init; }
Property Value
Gen2Collections
Number of Gen2 garbage collections since process start.
public int Gen2Collections { get; init; }
Property Value
JsonOptions
The canonical JsonSerializerOptions to use when reading or writing MemorySnapshot JSON. Pins the on-disk format so future framework-default changes (e.g. a globally-registered JsonStringEnumConverter elsewhere) cannot silently shift the enum-keyed dictionary representation.
public static JsonSerializerOptions JsonOptions { get; }
Property Value
TextureBytesByScene
Texture bytes grouped by scene tag (Story 12.3 Task 1). Empty-string key holds untagged assets. May be empty when no scene-aware capture is available.
public IReadOnlyDictionary<string, long>? TextureBytesByScene { get; init; }
Property Value
TotalAllocatedBytesSinceStart
Cumulative allocations since process start (GC.GetTotalAllocatedBytes(precise: false)).
public long TotalAllocatedBytesSinceStart { get; init; }