Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit a5b7466

Browse files
committed
move initial MemoryPoolBlock2s into Gen2
1 parent 1ec965d commit a5b7466

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Microsoft.AspNet.Server.Kestrel/KestrelServer.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.AspNet.Http.Features;
1010
using Microsoft.AspNet.Server.Kestrel.Http;
1111
using Microsoft.Extensions.Logging;
12+
using System.Runtime;
1213

1314
namespace Microsoft.AspNet.Server.Kestrel
1415
{
@@ -83,6 +84,19 @@ public void Start(RequestDelegate requestDelegate)
8384
}
8485

8586
engine.Start(information.ThreadCount == 0 ? 1 : information.ThreadCount);
87+
88+
// Move all MemoryPoolBlock2 into Gen2
89+
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
90+
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);
91+
GC.WaitForPendingFinalizers();
92+
93+
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
94+
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);
95+
GC.WaitForPendingFinalizers();
96+
97+
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
98+
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);
99+
86100
var atLeastOneListener = false;
87101

88102
foreach (var address in information.Addresses)

0 commit comments

Comments
 (0)