We’ve identified a memory leak in Drools when using JPAKnowledgeService.loadStatefulKnowledgeSession.
We’ve raised the issue here
https://issues.jboss.org/browse/JBRULES-3303?focusedCommentId=12647082#comment-12647082
The problem is that the InputMarshaller ends up registering a listener on the knowledge base twice, but only cleans up one of them when the session is disposed. This results in the KnowledgeBase keeping a reference to the session and leaking
memory.
I’ve done an analysis of it and the fix appears to be changing InputMarshaller line 204 from
session.setKnowledgeRuntime(new StatefulKnowledgeSessionImpl(session));
to
new StatefulKnowledgeSessionImpl(session);
The sessionImpl calls session.setKnowledgeRuntime() during the constructor.
I’ve attached a fuller explanation to the issue and there is sample code there as well.
It would be great if this could be applied to the 5.3 branch as we need this fix in order to be able to deploy our application.
Thanks,
Thomas