Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-2203

Regression: Memory leak in DeploymentContextImpl.stores

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 1.4.0.Final
    • core
    • 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());
      		}
      	}
      
      }
      

            Unassigned Unassigned
            rdicroce Richard DiCroce (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: