public static void WriteGroupedTasks(this TextWriter w, IEnumerable <TaskInfo> tasks) { foreach (var group in tasks.GroupBy(o => o.MethodName).OrderByDescending(g => g.Count())) { w.WriteLine($"{group.Count()}\t{ClrMdUtils.MakeReadableTypeName(group.Key)}"); } }
public static void WriteGroupedHandles(this TextWriter w, IEnumerable <HandleInfo> handles) { w.WriteLine("Handles:\n"); foreach (var g in handles.GroupBy(h => h.ClrHandle?.Type.Name ?? "").OrderByDescending(g => g.Count())) { w.WriteLine($"{g.Count()}\t{ClrMdUtils.MakeReadableTypeName(g.Key)}"); } }
public IEnumerable <ObjectInfo> EnumerateManagedWorkItems() { ClrStaticField workQueueField = ClrMdUtils.GetCorlib(runtime).GetTypeByName("System.Threading.ThreadPoolGlobals")?.GetStaticFieldByName("workQueue"); if (workQueueField != null) { object workQueueValue = workQueueField.GetValue(domain); ulong workQueueRef = (workQueueValue == null) ? 0L : (ulong)workQueueValue; if (workQueueRef != 0) { ClrType workQueueType = heap.GetObjectType(workQueueRef); // should be System.Threading.ThreadPoolWorkQueue if (workQueueType?.Name == "System.Threading.ThreadPoolWorkQueue") { foreach (var item in EnumerateThreadPoolWorkQueue(workQueueRef)) { yield return(new ObjectInfo { Address = item, Type = heap.GetObjectType(item) }); } } } } }