Table of Contents

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

CapturedAtUtc DateTime

UTC timestamp the snapshot was assembled. Sampled before the data reads so it is never later than the data it describes.

BytesByCategory IReadOnlyDictionary<MemoryCategory, long>

Bytes attributed to each MemoryCategory. Every enum value is present; absent values would be a bug.

Gen0Collections int

Number of Gen0 garbage collections since process start (GC.CollectionCount(0)).

Gen1Collections int

Number of Gen1 garbage collections since process start.

Gen2Collections int

Number of Gen2 garbage collections since process start.

TotalAllocatedBytesSinceStart long

Cumulative allocations since process start (GC.GetTotalAllocatedBytes(precise: false)).

Description string

Free-form label for the snapshot (e.g., scenario name or user-supplied tag).

TextureBytesByScene IReadOnlyDictionary<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.

AssetCountsByScene IReadOnlyDictionary<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

IReadOnlyDictionary<string, AssetCounts>

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

IReadOnlyDictionary<MemoryCategory, long>

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

DateTime

Description

Free-form label for the snapshot (e.g., scenario name or user-supplied tag).

public string Description { get; init; }

Property Value

string

Gen0Collections

Number of Gen0 garbage collections since process start (GC.CollectionCount(0)).

public int Gen0Collections { get; init; }

Property Value

int

Gen1Collections

Number of Gen1 garbage collections since process start.

public int Gen1Collections { get; init; }

Property Value

int

Gen2Collections

Number of Gen2 garbage collections since process start.

public int Gen2Collections { get; init; }

Property Value

int

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

JsonSerializerOptions

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

IReadOnlyDictionary<string, long>

TotalAllocatedBytesSinceStart

Cumulative allocations since process start (GC.GetTotalAllocatedBytes(precise: false)).

public long TotalAllocatedBytesSinceStart { get; init; }

Property Value

long