Esempio n. 1
0
        private bool TryGetSegmentMemoryRange(ClrSegment segment, GCGeneration generation, out ulong start, out ulong end)
        {
            start = 0;
            end   = 0;
            switch (generation)
            {
            case GCGeneration.Generation0:
                if (segment.IsEphemeralSegment)
                {
                    start = segment.Generation0.Start;
                    end   = segment.Generation0.End;
                }
                return(start != end);

            case GCGeneration.Generation1:
                if (segment.IsEphemeralSegment)
                {
                    start = segment.Generation1.Start;
                    end   = segment.Generation1.End;
                }
                return(start != end);

            case GCGeneration.Generation2:
                if (!(segment.IsLargeObjectSegment || segment.IsPinnedObjectSegment))
                {
                    start = segment.Generation2.Start;
                    end   = segment.Generation2.End;
                }
                return(start != end);

            case GCGeneration.LargeObjectHeap:
                if (segment.IsLargeObjectSegment)
                {
                    start = segment.Start;
                    end   = segment.End;
                }
                return(start != end);

            case GCGeneration.PinnedObjectHeap:
                if (segment.IsPinnedObjectSegment)
                {
                    start = segment.Start;
                    end   = segment.End;
                }
                return(start != end);

            default:
                return(false);
            }
        }
Esempio n. 2
0
        public IEnumerable <ClrObject> EnumerateObjectsInGeneration(GCGeneration generation)
        {
            foreach (var segment in _heap.Segments)
            {
                if (!TryGetSegmentMemoryRange(segment, generation, out var start, out var end))
                {
                    continue;
                }

                var       currentObjectAddress = start;
                ClrObject currentObject;
                do
                {
                    currentObject = _heap.GetObject(currentObjectAddress);
                    if (currentObject.Type != null)
                    {
                        yield return(currentObject);
                    }

                    currentObjectAddress = segment.GetNextObjectAddress(currentObject);
                } while (currentObjectAddress > 0 && currentObjectAddress < end);
            }
        }
Esempio n. 3
0
 public DumpGen(ClrMDHelper helper, GCGeneration generation)
 {
     _helper     = helper;
     _generation = generation;
 }