After deploying a huge amount of Java application in a JBoss EAP environment, it looks like a lot of Jandex index are retained in heap:
Test done with heap defined with 4Gb, started nicely with about ~150 applications and slowly increased it until about 200. Less heap then that leads into OOME.
Heap: Size: 1.4 GB Classes: 49.5k Objects: 38.6m Class Loader: 1.8 + 900mb ready for GC.
The same behavior is not seen in EAP 6.4.21 and all those 200 can be easily deployed within 1 GB heap size.
EDIT: A bit of Weld background*
org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry currently holds a map and a set. The set is in fact a subset of map's values - it contains bootstrap services.
Now, org.jboss.weld.bootstrap.BeanDeployment object creation entails copying of services which is done based on map keys. This works fine unless the set contains duplicate classes twice which can happen when deploying on WFLY.
Solution is to remove this set and only operate on the map.
Along with that we should also modify WeldStartup.endInitialization() to contain following one-liner that will force clean all the instances: