Details
Description
When a server is force disconnected, any of its DistributedRegions will not be GCed after they are closed. This is really only a problem if the GemFireCacheImpl is referenced in something other than the ClusterDistributionManager.cache field (in my test, I used a static field of a Function)
The GemFireCacheImpl references a ClusterDistributionManager in the final field called dm.
The DistributedRegion creates and references a DistributionAdvisor in the final field called distAdvisor. The DistributionAdvisor creates a MembershipListener and adds it to the ClusterDistributionManager's membershipListeners.
When the GemFireCacheImpl is closed due to force disconnect, its regions are also closed.
When a DistributedRegion is closed, its DistributionAdvisor is also closed.
DistributionAdvisor.close attempts to remove the MembershipListener
try { getDistributionManager().removeMembershipListener(membershipListener); } catch (CancelException e) { // if distribution has stopped, above is a no-op. } ...
That call fails with a CancelException, and the MembershipListener is not removed, so the ClusterDistributionManager references both the GemFireCacheImpl and the MembershipListener. The MembershipListener references the DistributionAdvisor which references the DistributedRegion.