From 5a4e4c9338ab0e706e6029f2c1937f1e7fa9d0c3 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 20 Feb 2024 12:22:46 +0100 Subject: [PATCH] test --- .../JavaScript/WebWorkerTest.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs index 514741a6b8753b..3ffee20613674d 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/WebWorkerTest.cs @@ -4,6 +4,7 @@ using System.IO; using System.Threading.Tasks; using System.Threading; +using System.Collections.Generic; using Xunit; namespace System.Runtime.InteropServices.JavaScript.Tests @@ -470,6 +471,42 @@ await executor.Execute(async () => }, cts.Token); } + [OuterLoop] + [Fact] + public async Task VeryLongRunningGC() + { + using var cts = new CancellationTokenSource(); + for(int i=0;i<100;i++) + { + var executor = new Executor(ExecutorType.NewThread); + Console.WriteLine("VeryLongRunningGC " + executor.Type + " " + i); + await executor.Execute(() => + { + long cnt = 0; + long[] data = new long[1024*1024*32]; + var end = DateTime.Now + TimeSpan.FromMilliseconds(10000); + do + { + // these are just dummy computations to keep CPU busy + Interlocked.Increment(ref cnt); + data = new long[1024*1024*32]; + data[0] = cnt; + + // force some GC + if(cnt % 10000 == 0) + { + GC.Collect(); + var total = GC.GetTotalMemory(true); + Console.WriteLine("GC.GetTotalMemory: "+total); + } + } + while(DateTime.Now