Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ScavengeKeys()

void System.ComponentModel.WeakHashtable.ScavengeKeys ( )
inlineprivate

Definition at line 91 of file WeakHashtable.cs.

92 {
93 int count = Count;
94 if (count == 0)
95 {
96 return;
97 }
98 if (_lastHashCount == 0)
99 {
101 return;
102 }
103 long totalMemory = GC.GetTotalMemory(forceFullCollection: false);
104 if (_lastGlobalMem == 0L)
105 {
107 return;
108 }
109 float num = (float)(totalMemory - _lastGlobalMem) / (float)_lastGlobalMem;
110 float num2 = (float)(count - _lastHashCount) / (float)_lastHashCount;
111 if (num < 0f && num2 >= 0f)
112 {
113 List<object> list = null;
114 foreach (object key in Keys)
115 {
116 if (key is WeakReference { IsAlive: false } weakReference)
117 {
118 if (list == null)
119 {
120 list = new List<object>();
121 }
122 list.Add(weakReference);
123 }
124 }
125 if (list != null)
126 {
127 foreach (object item in list)
128 {
129 Remove(item);
130 }
131 }
132 }
135 }
virtual ICollection Keys
Definition Hashtable.cs:532

References System.ComponentModel.WeakHashtable._lastGlobalMem, System.ComponentModel.WeakHashtable._lastHashCount, System.count, System.Collections.Hashtable.Count, System.GC.GetTotalMemory(), System.item, System.key, System.Collections.Hashtable.Keys, System.L, System.list, and System.ComponentModel.Remove.

Referenced by System.ComponentModel.WeakHashtable.SetWeak().