-
Notifications
You must be signed in to change notification settings - Fork 659
/
Copy pathGCTest.cs
124 lines (104 loc) · 2.53 KB
/
GCTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestCases
{
public static class GCTest
{
static DataManager dataManager;
public static void Start()
{
Console.WriteLine("Start!");
dataManager = new DataManager();
dataManager.FillCollections();
}
public static void CallGC()
{
Console.WriteLine("CallGC!");
dataManager.CallGC();
}
public static void TestDicEnumerator()
{
Dictionary<string, int> p3 = new Dictionary<string, int>();
p3["1"] = 1;
p3["2"] = 2;
string key;
Dictionary<string, int>.Enumerator enumerator = p3.GetEnumerator();
while (enumerator.MoveNext())
{
key = enumerator.Current.Key;
Console.WriteLine(key);
}
}
}
class DataManager
{
//ArrayCollectionA ca;
//ArrayCollectionB cb;
ListCollectionA ca;
ListCollectionB cb;
public void FillCollections()
{
//cb = new ArrayCollectionB();
//ca = new ArrayCollectionA(cb);
cb = new ListCollectionB();
ca = new ListCollectionA(cb);
}
public void CallGC()
{
cb = null;
ca = null;
}
}
public class ArrayCollectionA
{
int[] m_array;
ArrayCollectionB m_tb;
public ArrayCollectionA(ArrayCollectionB tb)
{
m_array = new int[10000000];
m_tb = tb;
m_tb.TestFun();
}
}
public class ArrayCollectionB
{
int[] m_array;
public ArrayCollectionB()
{
m_array = new int[10000000];
}
public void TestFun()
{
Console.WriteLine("Fill Start");
}
}
public class ListCollectionA
{
List<IntWarp> m_list;
ListCollectionB lcb;
public ListCollectionA(ListCollectionB lcb)
{
m_list = new List<IntWarp>(1000000);
this.lcb = lcb;
lcb.TestFun();
}
}
public class ListCollectionB
{
List<IntWarp> m_list;
public ListCollectionB()
{
m_list = new List<IntWarp>(1000000);
}
public void TestFun()
{
Console.WriteLine("Fill Start");
}
}
public class IntWarp
{
public int i;
}
}