Skip to content

Commit 0f52d78

Browse files
committed
C# side - Encourage the GC to clean up more often
1 parent ff2fdf1 commit 0f52d78

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Utils/Utilities.cs

+10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ public static void PrepUtils()
3535
Program.TickNoGenerationsEvent += MemCleaner.TickNoGenerations;
3636
Program.TickEvent += SystemStatusMonitor.Tick;
3737
Program.SlowTickEvent += AutoRestartCheck;
38+
int subticks = 0;
39+
Program.SlowTickEvent += () =>
40+
{
41+
GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized, false, false);
42+
if (subticks++ > 20)
43+
{
44+
subticks = 0;
45+
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, false, true);
46+
}
47+
};
3848
new Thread(TickLoop).Start();
3949
}
4050

0 commit comments

Comments
 (0)