-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
1.4.0.Final
-
None
DeploymentContexts are never destroyed. This creates a memory leak and can lead to OOME due to heap exhaustion.
This was previously reported as ARQ-1949. Comments on that issue indicate it was fixed somewhere between 1.1.7 and 1.1.13. The final comment cites ARQ-1992, but the fix for that issue doesn't appear related to this problem at all. In any case, if this was fixed, it has since regressed. AFAICT there is no code that ever calls DeploymentContext#destroy() anywhere in Arquillian.
For anyone else affected by this issue, there is a workaround. Create a LoadableExtension that properly destroys the deployment after it is no longer needed:
public class ArquillianLeakFix implements LoadableExtension { @Override public void register(ExtensionBuilder builder) { builder.observer(DeploymentDestroyer.class); } public static class DeploymentDestroyer { @Inject private Instance<DeploymentContext> deploymentContext; public void destroyDeployment(@Observes(precedence = Integer.MIN_VALUE) final UnDeployDeployment event) { deploymentContext.get().destroy(event.getDeployment()); } } }