JBoss Community

reuse StatefulKnowledgeSession, is StatefulKnowledgeSession lightweight

created by Nick Tan in jBPM - View the full discussion

hi, folks

 

i'm using jBPM5 and here is question about how to effectively use the StatefulKnowledgeSession.

 

is StatefulKnowledgeSession lightweight?

 

is there any potential risk if we implement the strategy that create StatefulKnowledgeSession for each request, that means, create StatefulKnowledgeSession when every time call startProcess, and dispose it after the process instance complete.

 

I read the javadoc of StatefulKnowledgeSession, it clear state that: "

After the application finishes using the session, though, it must call the dispose() method in order to free the resources and used memory.

"

 

at this monment, what i can image is that, if there are lots of active process instance not complete, that will cause lots of StatefulKnowledgeSession resources not released, which could be potential memory leak? is this correct?

 

do you guys have any best practice or pattern of useing StatefulKnowledgeSession? for example, options like:

reuse single StatefulKnowledgeSession?

reuse StatefulKnowledgeSession in a pool?

oneStatefulKnowledgeSession per request?

 

Thanks

Reply to this message by going to Community

Start a new discussion in jBPM at Community