Can I limit the number of timings stored by MiniProfiler (for .NET)?

Hi,

Duplicating a unanswered question from StackOverflow in the hope that it might get an answer here:

I’m using MiniProfiler in a .NET core app to time various stages in a 30 FPS video pipeline. This is a long-running executable, and memory used for Timing instances seems to grow without limit – unsurprisingly since a new Timing instance is created each time Step() is called.

In total about 2 GB of memory was consumed by MiniProfiler objects in one long test.

Is there any way to limit the number of Timings recorded, and say keep only the last N?

Failing that, I wonder how folks are able to use MiniProfiler in production; is there another way to avoid this issue? Or is it simply not targeted at use-cases like this (with perhaps 150 timings recorded per second)?

Thanks in advance!

MiniProfiler is built around a profiling session/request, not a rolling metrics buffer: Step() appends to the current profiler’s timing list, and I don’t think there’s a built-in cap on child timings within one profiler. For an always-on 30 FPS pipeline, I’d either start/stop a profiler per frame or short window and plug in a bounded custom storage implementation, or keep MiniProfiler for occasional diagnostic windows while using lightweight counters/histograms or a ring buffer for continuous timing. That avoids retaining every Timing instance.