diff options
Diffstat (limited to 'tests/src/GC/Scenarios')
-rw-r--r-- | tests/src/GC/Scenarios/DoublinkList/dlcollect.cs | 37 | ||||
-rw-r--r-- | tests/src/GC/Scenarios/DoublinkList/dlstack.cs | 49 | ||||
-rw-r--r-- | tests/src/GC/Scenarios/DoublinkList/doublinkgen.cs | 39 |
3 files changed, 94 insertions, 31 deletions
diff --git a/tests/src/GC/Scenarios/DoublinkList/dlcollect.cs b/tests/src/GC/Scenarios/DoublinkList/dlcollect.cs index a17e95a270..f7aa10dccb 100644 --- a/tests/src/GC/Scenarios/DoublinkList/dlcollect.cs +++ b/tests/src/GC/Scenarios/DoublinkList/dlcollect.cs @@ -11,6 +11,7 @@ namespace DoubLink { using System; using System.Collections.Generic; + using System.Runtime.CompilerServices; public class DLCollect { @@ -63,11 +64,38 @@ namespace DoubLink { } + [MethodImpl(MethodImplOptions.NoInlining)] + public bool DrainFinalizerQueue(int iRep, int iObj) + { + int lastValue = DLinkNode.FinalCount; + while (true) + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + + if (DLinkNode.FinalCount == iRep * iObj * 10) + { + return true; + } + + if (DLinkNode.FinalCount != lastValue) + { + Console.WriteLine(" Performing Collect/Wait/Collect cycle again"); + lastValue = DLinkNode.FinalCount; + continue; + } + + Console.WriteLine(" Finalized number stable at " + lastValue); + return false; + } + } public bool runTest(int iRep, int iObj) { Mv_Collect = new List<DoubLink>(iRep); + bool success = false; for(int i=0; i <10; i++) { SetLink(iRep, iObj); @@ -75,16 +103,13 @@ namespace DoubLink { GC.Collect(); } - GC.WaitForPendingFinalizers(); - - if (DLinkNode.FinalCount != iRep * iObj * 10) + if (DrainFinalizerQueue(iRep, iObj)) { - // see github#4093 for the rationale for fail-fast in this test. - Environment.FailFast(string.Empty); + success = true; } Console.WriteLine("{0} DLinkNodes finalized", DLinkNode.FinalCount); - return (DLinkNode.FinalCount==iRep*iObj*10); + return success; } diff --git a/tests/src/GC/Scenarios/DoublinkList/dlstack.cs b/tests/src/GC/Scenarios/DoublinkList/dlstack.cs index 5e207bec52..8fa63bf8fd 100644 --- a/tests/src/GC/Scenarios/DoublinkList/dlstack.cs +++ b/tests/src/GC/Scenarios/DoublinkList/dlstack.cs @@ -13,6 +13,7 @@ namespace DoubLink { using System; + using System.Runtime.CompilerServices; public class DLStack { @@ -63,36 +64,50 @@ namespace DoubLink { } + [MethodImpl(MethodImplOptions.NoInlining)] + public bool DrainFinalizerQueue(int iRep, int iObj) + { + int lastValue = DLinkNode.FinalCount; + while (true) + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + + if (DLinkNode.FinalCount == iRep * iObj * 10) + { + return true; + } + + if (DLinkNode.FinalCount != lastValue) + { + Console.WriteLine(" Performing Collect/Wait/Collect cycle again"); + lastValue = DLinkNode.FinalCount; + continue; + } + + Console.WriteLine(" Finalized number stable at " + lastValue); + return false; + } + } + public bool runTest(int iRep, int iObj) { - + bool success = false; for(int i=0; i <10; i++) { SetLink(iRep, iObj); MakeLeak(iRep); } - long lastTotalMemory = long.MaxValue; - long curTotalMemory = GC.GetTotalMemory(false); - - while (lastTotalMemory != curTotalMemory) - { - GC.Collect(); - GC.WaitForPendingFinalizers(); - - lastTotalMemory = curTotalMemory; - curTotalMemory = GC.GetTotalMemory(false); - } - - if (DLinkNode.FinalCount != iRep * iObj * 10) + if (DrainFinalizerQueue(iRep, iObj)) { - // see github#4093 for the rationale for fail-fast in this test. - Environment.FailFast(string.Empty); + success = true; } Console.WriteLine("{0} DLinkNodes finalized", DLinkNode.FinalCount); - return (DLinkNode.FinalCount==iRep*iObj*10); + return success; } diff --git a/tests/src/GC/Scenarios/DoublinkList/doublinkgen.cs b/tests/src/GC/Scenarios/DoublinkList/doublinkgen.cs index 76436ea7fe..0f1016c3d0 100644 --- a/tests/src/GC/Scenarios/DoublinkList/doublinkgen.cs +++ b/tests/src/GC/Scenarios/DoublinkList/doublinkgen.cs @@ -11,6 +11,7 @@ namespace DoubLink { using System; + using System.Runtime.CompilerServices; public class DoubLinkGen { @@ -61,25 +62,47 @@ namespace DoubLink { return 1; } + [MethodImpl(MethodImplOptions.NoInlining)] + public bool DrainFinalizerQueue(int iRep, int iObj) + { + int lastValue = DLinkNode.FinalCount; + while (true) + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + + if (DLinkNode.FinalCount == iRep * iObj) + { + return true; + } + + if (DLinkNode.FinalCount != lastValue) + { + Console.WriteLine(" Performing Collect/Wait/Collect cycle again"); + lastValue = DLinkNode.FinalCount; + continue; + } + + Console.WriteLine(" Finalized number stable at " + lastValue); + return false; + } + } public bool runTest(int iRep, int iObj) { SetLink(iRep, iObj); Mv_Doub = null; + bool success = false; - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); - - if (DLinkNode.FinalCount != iRep * iObj) + if (DrainFinalizerQueue(iRep, iObj)) { - // see github#4093 for the rationale for fail-fast in this test. - Environment.FailFast(string.Empty); + success = true; } Console.Write(DLinkNode.FinalCount); Console.WriteLine(" DLinkNodes finalized"); - return (DLinkNode.FinalCount==iRep*iObj); + return success; } |