diff --git a/source/Handlebars.Benchmark/EndToEnd.cs b/source/Handlebars.Benchmark/EndToEnd.cs index 379ab152..6bbf78ad 100644 --- a/source/Handlebars.Benchmark/EndToEnd.cs +++ b/source/Handlebars.Benchmark/EndToEnd.cs @@ -8,6 +8,7 @@ namespace HandlebarsNet.Benchmark { + [MemoryDiagnoser] public class EndToEnd { private object? _data; diff --git a/source/Handlebars.Benchmark/LargeArray.cs b/source/Handlebars.Benchmark/LargeArray.cs index 7b367e34..d7555393 100644 --- a/source/Handlebars.Benchmark/LargeArray.cs +++ b/source/Handlebars.Benchmark/LargeArray.cs @@ -7,6 +7,7 @@ namespace HandlebarsNet.Benchmark { + [MemoryDiagnoser] public class LargeArray { private object _data = null!; // -> Setup() diff --git a/source/Handlebars/Runtime/BoxedValues.cs b/source/Handlebars/Runtime/BoxedValues.cs index d2bfc5fa..5918f399 100644 --- a/source/Handlebars/Runtime/BoxedValues.cs +++ b/source/Handlebars/Runtime/BoxedValues.cs @@ -11,7 +11,10 @@ namespace HandlebarsDotNet.Runtime /// public static class BoxedValues { - private const int BoxedIntegersCount = 20; + // Covers iterator indexes for effectively all template loops. The cache is + // ~32KB of process-lifetime statics (1024 boxes + the array), traded against + // a 24-byte allocation per iteration index >= the cache size on every render. + private const int BoxedIntegersCount = 1024; private static readonly object[] BoxedIntegers = new object[BoxedIntegersCount]; static BoxedValues()