1
votes

In my application I'm loading nearly 10,000 rule to Drools ( Drools 5.5.0.final). But application throws java.lang.OutOfMemoryError Exception. My jvm args ,

-Xms1024m
-Xmx1024m

Can anyone help me to resolve this. I also used BigMemory ( http://terracotta.org/products/bigmemory) but still getting the same error.

Thanks in advance !

2
Do you have enough PermGen? When Drools compiles the rules , it creates a fair number of generated classes.Augusto
Viraj:: Can u plz say about the Heap size and permGen you had, to hold 10,000 rules. I am in need of that...Arun

2 Answers

2
votes

Use a profiler like VisualVM (free and very easy to run) to see how memory over time graph and take a heap snapshot just before it goes OutOfMemory.

Especially that graph can tell you some interesting things (by adding some Thread.sleep's in your code) which could give you and us a clue what's causing it:

  • how much memory you consume before starting anything drools (so just having your dataset in memory)
  • how much memory having the rules in memory consumes (so the KnowledgeBase)
  • how memory evolves onces you start a drools session from that base and insert your dataset.
0
votes

This may happen when you resuse the same 'statefulKnowledgeSession' for triggering process each time. In this case for each statefulKnowledgeSession.insert(fact) new facts are inserted but not removing prevous ones. Is that your case please remove/retract previously inserted facts before triggering new processinsatance using:

`ksession.retract(factHandle);