Class RingBufferMemorySink
- Namespace
- PopcorningGuineaPig.Engine.Diagnostics
- Assembly
- PopcorningGuineaPig.Engine.dll
Keeps the last N snapshots in memory. Useful for "always-on" sampling at a fixed interval with no I/O cost; flush to disk on demand via a FileMemorySink when something interesting happens.
public sealed class RingBufferMemorySink : IMemorySink
- Inheritance
-
RingBufferMemorySink
- Implements
- Inherited Members
Constructors
RingBufferMemorySink(int)
Creates a ring buffer with capacity capacity. Default 60
holds one minute at 1 Hz sampling.
public RingBufferMemorySink(int capacity = 60)
Parameters
capacityint
Properties
Capacity
Maximum number of retained snapshots. Set at construction time.
public int Capacity { get; }
Property Value
Count
Number of snapshots currently retained (≤ Capacity). Increases until the buffer fills, then stays constant as old snapshots get overwritten.
public int Count { get; }
Property Value
Snapshots
Snapshots in arrival order, oldest first. Returns a fresh list — safe to iterate / hand to a serializer without holding the buffer's lock.
public IReadOnlyList<MemorySnapshot> Snapshots { get; }
Property Value
Methods
Receive(MemorySnapshot)
Hand a snapshot to the sink. Should not throw under normal conditions.
public void Receive(MemorySnapshot snapshot)
Parameters
snapshotMemorySnapshot