Garbage collection size

The Garbage Collection size (GC size) of an instance is the amount of memory that is freed if the corresponding instance is garbage collected.

It is calculated by the Shallow Size of the instance plus the shallow size of all instances that are kept alive by this Instance. The following graph depicts a simplified Heap snapshot with 6 Instances.

Calculating garbage collection size
Calculating garbage collection size

The GC size of instance A is calculated by summing up the shallow size of all instances that it keeps alive. This is A + C + E = 150.

Although instance F is also referenced by A, it is not garbage-collected because it is still referenced by B. For B the GC size is B + D = 60. Again, F is not garbage-collected if only B is garbage-collected.

The previous figure depicts the GC sizes of all other instances.

The two colored shapes also represent the Keep Alive Set dashlet of A and B, respectively.