Class MemorySnapshot
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.
Implements
Inherited Members
Namespace: PopcorningGuineaPig.Engine.Diagnostics
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public sealed record MemorySnapshot : IEquatable<MemorySnapshot>
Constructors
| Edit this page View SourceMemorySnapshot(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.
Declaration
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
| Type | Name | Description |
|---|---|---|
| DateTime | CapturedAtUtc | UTC timestamp the snapshot was assembled. Sampled before the data reads so it is never later than the data it describes. |
| IReadOnlyDictionary<MemoryCategory, long> | BytesByCategory | Bytes attributed to each MemoryCategory. Every enum value is present; absent values would be a bug. |
| int | Gen0Collections | Number of Gen0 garbage collections since process start ( |
| int | Gen1Collections | Number of Gen1 garbage collections since process start. |
| int | Gen2Collections | Number of Gen2 garbage collections since process start. |
| long | TotalAllocatedBytesSinceStart | Cumulative allocations since process start ( |
| string | Description | Free-form label for the snapshot (e.g., scenario name or user-supplied tag). |
| IReadOnlyDictionary<string, long> | 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. |
| IReadOnlyDictionary<string, AssetCounts> | AssetCountsByScene | Asset counts grouped by scene tag (Story 12.3 Task 1). Empty-string key holds untagged assets. |
Properties
| Edit this page View SourceAssetCountsByScene
Asset counts grouped by scene tag (Story 12.3 Task 1). Empty-string key holds untagged assets.
Declaration
public IReadOnlyDictionary<string, AssetCounts>? AssetCountsByScene { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, AssetCounts> |
BytesByCategory
Bytes attributed to each MemoryCategory. Every enum value is present; absent values would be a bug.
Declaration
public IReadOnlyDictionary<MemoryCategory, long> BytesByCategory { get; init; }
Property Value
| Type | Description |
|---|---|
| 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.
Declaration
public DateTime CapturedAtUtc { get; init; }
Property Value
| Type | Description |
|---|---|
| DateTime |
Description
Free-form label for the snapshot (e.g., scenario name or user-supplied tag).
Declaration
public string Description { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
Gen0Collections
Number of Gen0 garbage collections since process start (GC.CollectionCount(0)).
Declaration
public int Gen0Collections { get; init; }
Property Value
| Type | Description |
|---|---|
| int |
Gen1Collections
Number of Gen1 garbage collections since process start.
Declaration
public int Gen1Collections { get; init; }
Property Value
| Type | Description |
|---|---|
| int |
Gen2Collections
Number of Gen2 garbage collections since process start.
Declaration
public int Gen2Collections { get; init; }
Property Value
| Type | Description |
|---|---|
| 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.
Declaration
public static JsonSerializerOptions JsonOptions { get; }
Property Value
| Type | Description |
|---|---|
| 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.
Declaration
public IReadOnlyDictionary<string, long>? TextureBytesByScene { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, long> |
TotalAllocatedBytesSinceStart
Cumulative allocations since process start (GC.GetTotalAllocatedBytes(precise: false)).
Declaration
public long TotalAllocatedBytesSinceStart { get; init; }
Property Value
| Type | Description |
|---|---|
| long |