When using a security domain with cache-type="default" then the ModuleClassLoader instances related to deployments leak through JBossCachedAuthenticationManager. The problematic piece of code is the domainCache member variable which in the DomainInfo value holds a LoginContext instance. This LoginContext has member contextClassLoader which causes the leak. (It points to the ModuleClassLoader of the deployment). One option to solve this issue could be to remove the cache entries which are related to the undeployed application. Steps to reproduce: 1) Add a user to the ApplicationRealm (linked with "other" security domain) ./add-user.sh -a -u user1 -p password1! -r ApplicationRealm -g app-user 2) start the AS ./standalone.sh 2) deploy a web application with a secured servlet allowing access to role "app-user" (No security domain is referenced in the jboss-web.xml, so the default domain "other" is used.) ./jboss-cli -c "deploy /tmp/secured-webapp.war" 3) open the servlet URL in the browser and login as a "user1" with password "password1!" 4) redeploy the application ./jboss-cli -c "undeploy secured-webapp.war" ./jboss-cli -c "deploy /tmp/secured-webapp.war" => LEAK - the first deployment's ModuleClassLoader is not destroyed, because it's referenced through the LoginContext instance from the JBossCachedAuthenticationManager
https://github.com/ehsavoie/jboss-eap/tree/BZ-1103735 waiting for new picketbox release.
Verification failed. I still see the ModuleClassLoader referenced from the DomainInfo.
Created attachment 940023 [details] secured-webapp.war Use the attached reproducer. After the 2nd deployment use Eclipse Memory Analyzer (MAT) to dump the heap and make following steps: 1) Open OQL view and run following query: SELECT f FROM org.jboss.modules.ModuleClassLoader f WHERE (f.module.identifier.name.toString() = "deployment.secured-webapp.war") 2) Select each entry and use context menu (right click) to run command: Merge Shortest Paths to GC Roots->Exclude all phantom/weak/soft etc. references 3) Check the references (look at the attached screenshot)
Created attachment 940024 [details] Screenshot - Eclipse MAT
I don't see the same results as you Josef. Could you help me with MAT ? The old module loader is still here BUT there is no references attached to it
PR: https://github.com/jbossas/jboss-eap/pull/1822