Issue:

Application crashed due to memory leak. This happens after executing the drools rule engine multiple times.

Solution:

Ensure that the Bean configuration is only creating and returning the KieContainer. The KieSession has to be created and disposed by the executor.

Bean Configuration

Copy to Clipboard

 

Executor

Copy to Clipboard

 

If the kieSession is created by the BeanConfiguration, when the kieSession is executed for the second time an error will be thrown. The error indicates that the session is missing. If kieSession.dispose() is not call at the end, the kieSession and all the objects related to it will not be cleard. This will cause the memory leak