Getting Out Of Memory error

65 views
Skip to first unread message

Suresh Babu

unread,
Jan 13, 2025, 12:52:14 AMJan 13
to Drools Usage

Hi Team,

We have a project where we are using Drools 7.72 version with Business Central & KIE .

We have deployed a project from Business Central which has just a java data object and a simple guided decision table and deployed it onto the KIE server.

We are calling this Guided Decision table from a spring boot project via parallel streams for each of our data.

This has siginificantly increased the memory usage and we see memory leaks in the heap dump pointing to Rule Engine data objects that are consumed within KIE server.

So my question is, 

Can we call a guided decision table via standard KIE-API's in a parallel stream ? or should we use only streams ?

Is there any limitations in using parallel streams ?

Also I have deployed the Rule Engine project using "per request" runtime strategy...but when I called the Rule Engine project via the KIE dependent library API's from spring boot project ...I see in the heap dump that its making a stateful session.

So Pls clarify how to rectify the Out of Memory issue.

Thanks.

Suresh

Toshiya Kobayashi

unread,
Jan 13, 2025, 10:42:02 PMJan 13
to Drools Usage
Hi,

Stateless session should resolve the memory issue.

"per request" runtime strategy is not related to stateless/stateful. I think you can configure stateless/stateful in Project Editor in Business Central https://docs.drools.org/7.73.0.Final/drools-docs/html_single/#_kie_bases_and_sessions

Toshiya

2025年1月13日月曜日 14:52:14 UTC+9 sures...@gmail.com:

Suresh Babu

unread,
Jan 14, 2025, 1:04:15 AMJan 14
to Drools Usage
Hi Toshiya,
Thanks for the response.

We are using BatchCommands and then using restTemplate to call the GuidedDecision table via REST KIE URL.

It seems by default BatchCommands create stateful session.
Now I have modified the Rule Engine Project in Business Central to use the KIE-Base & Stateless session by editing the project settings.

Even then when calling via batch commands and then using rest template, the memory is still going high.

Not sure where its going wrong? Is there a way to call dispose & retract using Batch commands so to destroy all the defaultFactHandle ? coz this DefaultFactHandle is occupying 1.9GB out of 2GB memory.

Thanks,
Suresh Babu

Toshiya Kobayashi

unread,
Jan 14, 2025, 9:16:43 PMJan 14
to Drools Usage
To use stateless session, you just need to specify the ksession name which you configured as "stateless" in Project Editor.

https://github.com/tkobayas/kiegroup-examples/blob/master/Ex-kie-server-client-7.61/src/test/java/com/sample/StatelessTest.java#L53

Do you specify that?

Toshiya

2025年1月14日火曜日 15:04:15 UTC+9 sures...@gmail.com:

Suresh Babu

unread,
Jan 15, 2025, 12:06:52 AMJan 15
to Drools Usage
Yes ..I have done that ...the latest load test results are promosing. So I think I am good now.

Also for my knowledge perspective just wanted to know whether is there a way to call retract & dispose methods on the client side which call the Rule Engine via the REST URL ?

Toshiya Kobayashi

unread,
Jan 15, 2025, 9:24:36 PMJan 15
to Drools Usage
> Also for my knowledge perspective just wanted to know whether is there a way to call retract & dispose methods on the client side which call the Rule Engine via the REST URL ?

With a stateful session, you can delete a fact and dispose a session.

example)
https://github.com/kiegroup/droolsjbpm-integration/blob/main/kie-server-parent/kie-server-tests/kie-server-integ-tests-drools/src/test/java/org/kie/server/integrationtests/drools/StatefulSessionUsageIntegrationTest.java#L323
https://github.com/kiegroup/droolsjbpm-integration/blob/main/kie-server-parent/kie-server-tests/kie-server-integ-tests-drools/src/test/java/org/kie/server/integrationtests/drools/StatefulSessionUsageIntegrationTest.java#L362

Note: When you use a stateful session in kie-server, it will be a single stateful session in the container, so delete and dispose may cause an unexpected outcome if there are multiple concurrent accesses. Generally, stateless is recommended.

Toshiya

2025年1月15日水曜日 14:06:52 UTC+9 sures...@gmail.com:
Reply all
Reply to author
Forward
0 new messages