summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSejong Oh <sejooh@microsoft.com>2016-04-01 16:09:00 -0700
committerSejong Oh <sejooh@microsoft.com>2016-04-01 16:09:00 -0700
commit030136228abccb8b6d4737f92358bec8a9a50c09 (patch)
tree2b5c9402358b775629837bf2d0cfbd7a011e333f /tests
parent531de762ff569f52049e35cb69032b9c3da22238 (diff)
downloadcoreclr-030136228abccb8b6d4737f92358bec8a9a50c09.tar.gz
coreclr-030136228abccb8b6d4737f92358bec8a9a50c09.tar.bz2
coreclr-030136228abccb8b6d4737f92358bec8a9a50c09.zip
Fix singlinkgen test.
If the address of SingLink is stored at stack, GC.Collect() cannot collect the object since the address variable is still alive at stack.
Diffstat (limited to 'tests')
-rw-r--r--tests/src/GC/Scenarios/SingLinkList/singlinkgen.cs19
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/src/GC/Scenarios/SingLinkList/singlinkgen.cs b/tests/src/GC/Scenarios/SingLinkList/singlinkgen.cs
index 028a1a34d7..db68ab7a4a 100644
--- a/tests/src/GC/Scenarios/SingLinkList/singlinkgen.cs
+++ b/tests/src/GC/Scenarios/SingLinkList/singlinkgen.cs
@@ -12,6 +12,7 @@
namespace SingLink {
using System;
+ using System.Runtime.CompilerServices;
public class SingLinkGen
{
@@ -72,17 +73,26 @@ namespace SingLink {
Console.WriteLine(retVal);
return ( retVal == iRep*iObj);
}
-
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ void Create(int iObj) {
+ Mv_Sing = new SingLink(iObj);
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ void Delete() {
+ Mv_Sing = null;
+ GC.Collect();
+ }
public int SetLink(int iRep, int iObj)
{
for(int i=0; i<iRep; i++)
{
- Mv_Sing = new SingLink(iObj);
+ Create(iObj);
//Console.WriteLine("after number {0} singlink is set: {1}", i, GC.GetTotalMemory(false) );
- Mv_Sing = null;
- GC.Collect();
+ Delete();
GC.WaitForPendingFinalizers();
}
@@ -147,3 +157,4 @@ namespace SingLink {
}
}
}
+