public static void LogObjectHoldPathsFor(IEnumerable <WeakReference> elements, Func <WeakReference, int> weight) { GC.Collect(); MemoryTracker.LockTracking(); try { Dictionary <object, MemoryTracker.ReferenceData> dictionary = new Dictionary <object, MemoryTracker.ReferenceData>(); HashSet <object> hashSet = new HashSet <object>(); MemoryTracker.foundCollections.Clear(); Queue <object> queue = new Queue <object>(); foreach (object current in from weakref in MemoryTracker.tracked.SelectMany((KeyValuePair <Type, HashSet <WeakReference> > kvp) => kvp.Value) where weakref.IsAlive select weakref.Target) { if (!hashSet.Contains(current)) { hashSet.Add(current); queue.Enqueue(current); } } foreach (Type current2 in GenTypes.AllTypes.Union(MemoryTracker.tracked.Keys)) { if (!current2.FullName.Contains("MemoryTracker") && !current2.FullName.Contains("CollectionsTracker")) { if (!current2.ContainsGenericParameters) { MemoryTracker.AccumulateStaticMembers(current2, dictionary, hashSet, queue); } } } int num = 0; while (queue.Count > 0) { if (num % 10000 == 0) { UnityEngine.Debug.LogFormat("{0} / {1} (to process: {2})", new object[] { num, num + queue.Count, queue.Count }); } num++; MemoryTracker.AccumulateReferences(queue.Dequeue(), dictionary, hashSet, queue); } if (elements != null && weight != null) { int num2 = 0; MemoryTracker.CalculateReferencePaths(dictionary, from kvp in dictionary where !kvp.Value.path.NullOrEmpty() select kvp.Key, num2); num2 += 1000; MemoryTracker.CalculateReferencePaths(dictionary, from kvp in dictionary where kvp.Value.path.NullOrEmpty() && kvp.Value.referredBy.Count == 0 select kvp.Key, num2); foreach (object current3 in from kvp in dictionary where kvp.Value.path.NullOrEmpty() select kvp.Key) { num2 += 1000; MemoryTracker.CalculateReferencePaths(dictionary, new object[] { current3 }, num2); } Dictionary <string, int> dictionary2 = new Dictionary <string, int>(); foreach (WeakReference current4 in elements) { if (current4.IsAlive) { string path = dictionary[current4.Target].path; if (!dictionary2.ContainsKey(path)) { dictionary2[path] = 0; } Dictionary <string, int> dictionary3; string key; (dictionary3 = dictionary2)[key = path] = dictionary3[key] + weight(current4); } } StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair <string, int> current5 in from kvp in dictionary2 orderby - kvp.Value select kvp) { stringBuilder.AppendLine(string.Format("{0}: {1}", current5.Value, current5.Key)); } Log.Message(stringBuilder.ToString()); } } finally { MemoryTracker.UnlockTracking(); } }