public virtual HashSet <ulong> GetAliveObjects([NotNull] ClrRuntime runtime) { var pinnedRoots = this.ExtractRootsFromRuntime(runtime); var heap = runtime.GetHeap(); var uniqueObjectsToStay = HashSetHelper.GetHashSet <ulong>(10 * 1000 * 1000); foreach (var pinnedRoot in pinnedRoots) { var type = heap.GetObjectType(pinnedRoot); if (type == null) { continue; } this.EnumerateObjectReferences(pinnedRoot, uniqueObjectsToStay, heap); } uniqueObjectsToStay.TrimExcess(); return(uniqueObjectsToStay); }