Null object somehow has data?

This one has me flummoxed. Look at the image below. I have a List<> of custom Building objects. One of the public variables of that object points to a MonoBehaviour I wrote called BuildingUIController. I took this screenshot at a breakpoint. Notice that the myUI variable is null, yet somehow, the building variable within that null behavior is NOT null. I can even print the contents of it. For example, this code:

print (buildings[1].myUI);
print (buildings[1].myUI.building);

produces this in the console:


Can someone please explain how this is possible?

What this means is that that object cannot be GC’d because something else has a reference to it. It goes a little like this:

Main game loop > myUI > building
Main game loop > something else > building

Then something happens where myUI is null
and therefore myUI has no references to it and is eligible for GC

HOWEVER, building may still have references to it that are not inside of the myUI that has been nulled.
In this way, the myUI is not GC’d because the building has a reference to its parent and cannot be finalized until all references to it are cleaned up.

Take a look at some basic GC logic: Fundamentals of garbage collection | Microsoft Learn