public void Can_find_instances_of_a_type() { var expectedNumber = _heap.EnumerateObjects().Count(o => o.Type.Name == typeof(ClassWithStringField).FullName); var proxies = _heap.GetProxies <ClassWithStringField>().ToList(); Assert.AreEqual(expectedNumber, proxies.Count); Assert.IsTrue(proxies.All(p => p.GetClrType().Name == typeof(ClassWithStringField).FullName)); }
private static void ShowConcurrentQueues(ClrHeap heap) { var queues = heap.GetProxies("System.Collections.Concurrent.ConcurrentQueue<System.Int32>"); int count = 1; foreach (var queue in queues) { Console.WriteLine($"Queue #{count}"); // a queue is managing a chained list of segments // each segment points to the next via its m_next field // stores the elements in its m_array field var segment = queue.m_head; while (segment != null) { for (int index = segment.m_low; index <= segment.m_high; index++) { var value = segment.m_array[index]; Console.WriteLine(value); } segment = segment.m_next; } count++; Console.WriteLine(); } }
private static void ShowConcurrentDictionaries(ClrHeap heap) { var dicos = heap.GetProxies("System.Collections.Concurrent.ConcurrentDictionary<System.Int32,System.String>"); foreach (var dico in dicos) { var buckets = dico.m_tables.m_buckets; Console.WriteLine($"{buckets.Length} buckets"); foreach (var bucket in buckets) { if (bucket == null) { continue; } var key = bucket.m_key; var value = bucket.m_value; Console.WriteLine($"{key} = {value}"); } Console.WriteLine(); } }