§2.1.(f) Effect on garbage collection
A role and its base object form one conceptual entity. The garbage collector will see a role
and its base object as linked in a bidirectional manner. As a result, a role cannot be
garbage collected if its base is still reachable and vice versa.
Internally a team manages its roles and corresponding bases using weak references.
When using one of the getAllRoles(..)
methods (see §6.1.(a)),
the result may be non-deterministic because these internal structures
may hold weak references to objects that will be collected by the next run of the
garbage collector. We advise clients of getAllRoles(..)
to call
System.gc()
prior to calling getAllRoles(..)
in order
to ensure deterministic results.