GcObject CreateRootObject() { GcObject rootObject = GcObject.CreateGcObject(rootCount); rootObject.TypeSizeStackTraceId = GetOrCreateGcType("<root>"); GcObject unknownObject = GcObject.CreateGcObject(0); unknownObject.TypeSizeStackTraceId = GetOrCreateGcType("<unknown type>"); for (int i = 0; i < rootCount; i++) { if (roots[i] == null) { roots[i] = idToObject[rootIDs[i]]; if (roots[i] == null) { roots[i] = unknownObject; } } roots[i].parent = null; roots[i].InterestLevel = InterestLevel.Interesting; rootObject.SetReference(i, roots[i]); } // patch up any unresolved forward references by making them point to "unknownObject" foreach (ForwardReference head in addressToForwardReferences.Values) { for (ForwardReference forwardReference = head; forwardReference != null; forwardReference = forwardReference.next) { forwardReference.source.SetReference(forwardReference.referenceNumber, unknownObject); } } addressToForwardReferences.Clear(); return(rootObject); }
internal GcObject CreateObject(int typeSizeStackTraceId, int numberOfReferences, ulong[] references) { GcObject o = GcObject.CreateGcObject(numberOfReferences); o.TypeSizeStackTraceId = typeSizeStackTraceId; for (int i = 0; i < numberOfReferences; i++) { GcObject target = idToObject[references[i]]; if (target != null) { o.SetReference(i, target); } else { CreateForwardReference(references[i], o, i); } } empty = false; return(o); }