Class PluginClassLoaderLeakSentinel

java.lang.Object
com.xebialabs.xlrelease.osgi.impl.PluginClassLoaderLeakSentinel

public class PluginClassLoaderLeakSentinel extends Object
A production safety net, independent of the CI-only leak-gate test suite: after PluginTeardown.teardown(com.xebialabs.xlrelease.osgi.impl.PluginRuntime) completes, watches whether a plugin's classloader actually becomes collectible within a bounded delay, and logs at ERROR - with the plugin's symbolic name and install/teardown timestamps - only once it is sure. Never throws, never affects any other plugin or host behavior.

GC policy: the initial DEFAULT_CHECK_DELAY wait is a courtesy - long enough that a JVM under normal load has almost certainly already run a GC cycle naturally, so the common case needs no forced collection at all. Only if the classloader is still not collectible at that point does this class force the issue: a bounded number of System.gc() calls, spaced out, specifically to rule out the case that mislead earlier versions of this check - a JVM tuned with a large max heap feels no memory pressure and can go a long time without an old-generation-inclusive collection, even though the classloader was never actually unreachable-but-uncollected forever, just not yet swept. Forcing GC only after first detecting non-collectibility (never unconditionally, never on the happy path) keeps this a rare, teardown-triggered cost rather than a standing tax on the host.