public static void LogGrownCollections() { if (!MemoryTracker.AnythingTracked) { Log.Message("No objects tracked, memory tracker markup may not be applied."); return; } CollectionsTracker.collections.RemoveAll((KeyValuePair <WeakReference, int> kvp) => !kvp.Key.IsAlive || ((ICollection)kvp.Key.Target).Count <= kvp.Value); MemoryTracker.LogObjectHoldPathsFor(from kvp in CollectionsTracker.collections select kvp.Key, delegate(WeakReference elem) { ICollection collection = elem.Target as ICollection; return(collection.Count - CollectionsTracker.collections[elem]); }); CollectionsTracker.collections.Clear(); }
private static void ObjectHoldPaths() { if (MemoryTracker.tracked.Count == 0) { Log.Message("No objects tracked, memory tracker markup may not be applied.", false); } else { GC.Collect(); MemoryTracker.LockTracking(); try { foreach (HashSet <WeakReference> table in MemoryTracker.tracked.Values) { MemoryTracker.CullNulls(table); } List <Type> list = new List <Type>(); list.Add(typeof(Map)); List <FloatMenuOption> list2 = new List <FloatMenuOption>(); foreach (Type type in list.Concat(from kvp in MemoryTracker.tracked orderby - kvp.Value.Count select kvp.Key).Take(30)) { Type type2 = type; HashSet <WeakReference> trackedBatch = MemoryTracker.tracked.TryGetValue(type2, null); if (trackedBatch == null) { trackedBatch = new HashSet <WeakReference>(); } list2.Add(new FloatMenuOption(string.Format("{0} ({1})", type2, trackedBatch.Count), delegate() { MemoryTracker.LogObjectHoldPathsFor(trackedBatch, (WeakReference _) => 1); }, MenuOptionPriority.Default, null, null, 0f, null, null)); if (list2.Count == 30) { break; } } Find.WindowStack.Add(new FloatMenu(list2)); } finally { MemoryTracker.UnlockTracking(); } } }
public static void LogObjectHoldPaths() { if (MemoryTracker.tracked.Count == 0) { Log.Message("No objects tracked, memory tracker markup may not be applied."); } else { GC.Collect(); MemoryTracker.LockTracking(); try { foreach (HashSet <WeakReference> value in MemoryTracker.tracked.Values) { MemoryTracker.CullNulls(value); } List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (KeyValuePair <Type, HashSet <WeakReference> > item in from kvp in MemoryTracker.tracked orderby - kvp.Value.Count select kvp) { KeyValuePair <Type, HashSet <WeakReference> > elementLocal = item; list.Add(new FloatMenuOption(string.Format("{0} ({1})", item.Key, item.Value.Count), delegate { MemoryTracker.LogObjectHoldPathsFor(elementLocal.Value, (WeakReference _) => 1); }, MenuOptionPriority.Default, null, null, 0f, null, null)); if (list.Count == 30) { break; } } Find.WindowStack.Add(new FloatMenu(list)); } finally { MemoryTracker.UnlockTracking(); } } }
internal void <> m__0() { MemoryTracker.LogObjectHoldPathsFor(this.trackedBatch, (WeakReference _) => 1); }