null

parent2

null

// At this point, the `child` instance is unreachable

// and will eventually be garbage collected.

Shallow size vs retained size

Shallow size includes only the size of the object
and its references, while retained size also includes
the size of the retained objects.

The retained size of the root object includes
all reachable Dart objects.

In the following example, the size of myHugeInstance
isn’t part of the parent’s or child’s shallow sizes,
but is part of their retained sizes:

class

Child

/// The instance is part of both [parent] and [parent.child]

/// retained sizes.

final

myHugeInstance

MyHugeInstance

();

class

Parent

Child