Пример #1
0
 private static void PrintMemoryRegionInfo(ClrRuntime runtime)
 {
     Console.ForegroundColor = ConsoleColor.DarkYellow;
     Console.WriteLine("\nMemory Region Information");
     Console.ResetColor();
     var seperator = "------------------------------------------------";
     Console.WriteLine(seperator);
     Console.WriteLine("{0,24} {1,4} {2,15}", "Type", "Count", "Total Size (MB)");
     Console.WriteLine(seperator);
     foreach (var region in (from r in runtime.EnumerateMemoryRegions()
                             //where r.Type != ClrMemoryRegionType.ReservedGCSegment
                             group r by r.Type into g
                             let total = g.Sum(p => (uint)p.Size)
                             orderby total descending
                             select new
                             {
                                 TotalSize = total,
                                 Count = g.Count(),
                                 Type = g.Key
                             }))
     {
         Console.WriteLine("{0,24} {1,5} {2,15:N2}", region.Type.ToString(), region.Count, region.TotalSize / 1024.0 / 1024.0);
     }
     Console.WriteLine(seperator);
 }
Пример #2
0
        private void AddCLRRegions(ClrRuntime runtime)
        {
            foreach (var region in runtime.EnumerateMemoryRegions())
            {
                // We don't need reserved memory in our dump
                if (region.Type == ClrMemoryRegionType.ReservedGCSegment)
                    continue;

                ulong address = region.Address;
                ulong endAddress = region.Address + region.Size;
                ulong existingEndAddress;
                if (_majorClrRegions.Find(ref address, out existingEndAddress))
                {
                    _majorClrRegions.Update(region.Address, Math.Max(existingEndAddress, endAddress));
                }
                else
                {
                    _majorClrRegions.Add(region.Address, endAddress);
                }
            }
        }