private static int?GenerationOf(ClrHeap heap, ClrObject obj) { ClrSegment segment = heap.GetSegmentByAddress(obj.Address); if (segment == null) { // This happen if the object is no longer live return(null); } else { return(segment.GetGeneration(obj)); } }
public static void SetGenerationStats(ClrSegment clrSeg, ulong addr, ulong size, int[] cnts, ulong[] sizes) { addr = Utils.RealAddress(addr); if (clrSeg.IsLarge) { cnts[0] += 1; sizes[0] += size; } else { var gen = clrSeg.GetGeneration(addr); if (gen >= 0) { cnts[gen] += 1; sizes[gen] += size; } } }
/// <summary> /// Returns the generation of an object in this segment. /// </summary> /// <param name="obj">An object in this segment.</param> /// <returns> /// The generation of the given object if that object lies in this segment. The return /// value is undefined if the object does not lie in this segment. /// </returns> /// <inheritdoc /> public int GetGeneration(ulong obj) => Segment.GetGeneration(obj);