From 43ecf9cc4b5ecb90fe61f936636a14f8eaca634b Mon Sep 17 00:00:00 2001 From: electricessence <5899455+electricessence@users.noreply.github.com> Date: Mon, 9 Nov 2026 18:17:45 -0800 Subject: [PATCH] The heap-growth test judges the median of its last rounds, so one noisy round cannot fail it Co-Authored-By: Claude Sonnet 5.5 --- .../LeakRetentionTests.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Tests/Open.Database.Extensions.Core.Tests/LeakRetentionTests.cs b/Tests/Open.Database.Extensions.Core.Tests/LeakRetentionTests.cs index 8455cf3..0ffaf90 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/LeakRetentionTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/LeakRetentionTests.cs @@ -190,7 +190,7 @@ public static void ProcedureNames_StayBounded_With10000DistinctProcedures() const int Calls = 3000; const int Rounds = 6; - // The growth allowed in each of the last rounds of calls, in bytes. Measured: 0 for nearly every terminal and round, and swings of up to about 13 KB + // The growth allowed in the median of the last rounds of calls, in bytes. Measured: 0 for nearly every terminal and round, and swings of up to about 13 KB // (no trend) for the dataflow block. A call that keeps one object, of at least 24 bytes, adds 72 KB a round. // (A zero bound would be unfair to the garbage collector: a round may happen to end a few KB higher.) const long MaxGrowth = 65_536; @@ -276,8 +276,10 @@ public static async Task ManyCalls_TheHeapDoesNotGrow(string terminal) last = now; } - long worst = growth.Skip(Rounds / 2).Max(); - Assert.True(worst <= MaxGrowth, $"Actual: {terminal}: bytes grown per round of {Calls} calls: {string.Join(", ", growth)}."); + // A leak grows the heap in every round, so judge the median of the last rounds: one noisy round (a loaded machine, Debug code) cannot fail the test, while a leak still does. + long[] tail = [.. growth.Skip(Rounds / 2).Order()]; + long median = tail[tail.Length / 2]; + Assert.True(median <= MaxGrowth, $"Actual: {terminal}: bytes grown per round of {Calls} calls: {string.Join(", ", growth)}."); } static long Settled()