public static void LogObjectsLoaded() { if (MemoryTracker.tracked.Count == 0) { Log.Message("No objects tracked, memory tracker markup may not be applied."); return; } GC.Collect(); MemoryTracker.LockTracking(); try { foreach (HashSet <WeakReference> current in MemoryTracker.tracked.Values) { MemoryTracker.CullNulls(current); } StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair <Type, HashSet <WeakReference> > current2 in from kvp in MemoryTracker.tracked orderby - kvp.Value.Count select kvp) { stringBuilder.AppendLine(string.Format("{0,6} {1}", current2.Value.Count, current2.Key)); } Log.Message(stringBuilder.ToString()); } finally { MemoryTracker.UnlockTracking(); } }
private static void ObjectsLoaded() { 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); } StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair <Type, HashSet <WeakReference> > keyValuePair in from kvp in MemoryTracker.tracked orderby - kvp.Value.Count select kvp) { stringBuilder.AppendLine(string.Format("{0,6} {1}", keyValuePair.Value.Count, keyValuePair.Key)); } Log.Message(stringBuilder.ToString(), false); } finally { MemoryTracker.UnlockTracking(); } } }
public static void Update() { if (MemoryTracker.tracked.Count != 0 && MemoryTracker.updatesSinceLastCull++ >= 10) { MemoryTracker.updatesSinceLastCull = 0; KeyValuePair <Type, HashSet <WeakReference> > keyValuePair = MemoryTracker.tracked.ElementAtOrDefault(MemoryTracker.cullTargetIndex++); if (keyValuePair.Value == null) { MemoryTracker.cullTargetIndex = 0; } else { MemoryTracker.CullNulls(keyValuePair.Value); } } }
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 Update() { if (MemoryTracker.tracked.Count != 0) { if (MemoryTracker.updatesSinceLastCull++ >= 10) { MemoryTracker.updatesSinceLastCull = 0; HashSet <WeakReference> value = MemoryTracker.tracked.ElementAtOrDefault(MemoryTracker.cullTargetIndex++).Value; if (value == null) { MemoryTracker.cullTargetIndex = 0; } else { MemoryTracker.CullNulls(value); } } } }
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(); } } }