@@ -13,6 +13,7 @@ namespace DoubLink {
13
13
using System . Threading ;
14
14
using System ;
15
15
using System . IO ;
16
+ using System . Runtime . CompilerServices ;
16
17
17
18
public class DLBigLeakThd
18
19
{
@@ -84,6 +85,23 @@ public static int Main(System.String [] Args)
84
85
85
86
86
87
public bool runTest ( int iRep , int iObj , int iThd )
88
+ {
89
+ CreateDLinkListsWithLeak ( iRep , iObj , iThd , 20 ) ;
90
+
91
+ GC . Collect ( ) ;
92
+ GC . WaitForPendingFinalizers ( ) ;
93
+ GC . Collect ( ) ;
94
+
95
+ int goal = iRep * 15 * iThd * iObj + 20 * iRep * iObj ;
96
+ Console . WriteLine ( "{0}/{1} DLinkNodes finalized" , DLinkNode . FinalCount , goal ) ;
97
+ return ( DLinkNode . FinalCount == goal ) ;
98
+ }
99
+
100
+
101
+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
102
+ // Do not inline the method that creates GC objects, because it could
103
+ // extend their live intervals until the end of the parent method.
104
+ public void CreateDLinkListsWithLeak ( int iRep , int iObj , int iThd , int iters )
87
105
{
88
106
this . iRep = iRep ;
89
107
this . iObj = iObj ;
@@ -94,7 +112,7 @@ public bool runTest(int iRep, int iObj, int iThd)
94
112
Mv_Thread [ i ] = new Thread ( new ThreadStart ( this . ThreadStart ) ) ;
95
113
Mv_Thread [ i ] . Start ( ) ;
96
114
}
97
- for ( int i = 0 ; i < 20 ; i ++ )
115
+ for ( int i = 0 ; i < iters ; i ++ )
98
116
{
99
117
SetLink ( iRep , iObj ) ;
100
118
MakeLeak ( iRep ) ;
@@ -103,15 +121,7 @@ public bool runTest(int iRep, int iObj, int iThd)
103
121
{
104
122
Mv_Thread [ i ] . Join ( ) ;
105
123
}
106
-
107
124
Mv_Doub = null ;
108
- GC . Collect ( ) ;
109
- GC . WaitForPendingFinalizers ( ) ;
110
- GC . Collect ( ) ;
111
-
112
- int goal = iRep * 15 * iThd * iObj + 20 * iRep * iObj ;
113
- Console . WriteLine ( "{0}/{1} DLinkNodes finalized" , DLinkNode . FinalCount , goal ) ;
114
- return ( DLinkNode . FinalCount == goal ) ;
115
125
}
116
126
117
127
0 commit comments