Just have a general question regarding memory management when using "Stateful sessions" in Drools. For context, I'm specifically looking to use a ksession in "Stream" mode, together with fireUntilHalt()
to process an infinite stream of events. Each event is timestamped, however I'm mainly writing rules using length-based windows notation (i.e. window:length()
) and the from accumulate
syntax for decision making.
The docs are a little vague though about how memory management works in this case. The docs suggest that using temporal operators the engine can automatically remove any facts/events that can no longer match. However, would this also apply to rules that only use the window:length()
? Or would my system need to manually delete events that are no longer applicable, in order to prevent running OOM?
window:time()
calculates expiration, so works for automatic removal. However, window:length()
doesn't calculate expiration, so events would be retained.
You can confirm the behaviour with my example: https://github.com/tkobayas/kiegroup-examples/tree/master/Ex-cep-window-length-8.32
You would need to explicitly delete them or set @expires
(if it's possible for your application to specify expiration with time) to avoid OOME.
Thank you for pointing that the document is not clear about it. I have filed a doc JIRA to explain it.