Kris,
In my own designs I usually avoid static specially in JEE environments.
In JEE environments I would create a pool of rulebases, either using
mbeans, local JNDI or stateful session beans with a controlled number of
instances that meets your needs. You need to fine tune to how heavy your
concurrency and rules are but, just as an example, lets say you expect to
have 50 concurrent users at any single instant, and then you find that the
ideal rate for you is to have 1 rulebase for each 10 sessions. So, you need
5 rulebase instances.
Once you have the pool, just have your stateless session beans that get a
reference to one of the rulebases to create a new stateless session, execute
there rules, and it is done.
[]s
Edson
2008/11/26 Kris Nuttycombe <kris.nuttycombe(a)gmail.com>
On Wed, Nov 26, 2008 at 1:10 PM, Edson Tirelli
<tirelli(a)post.com> wrote:
>
> Ok, lets start with a simple thing:
>
> 4128 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad6103ff0> of
> class
org.drools.rule.Pattern<http://carrot.gaiam.com:7000/class/0x2aaad6103ff0>
>
> I can't see how 16 rules can create that many patterns. Are you sure
> you are not recompiling/recreating your rulebase multiple times? If not,
> then we may have a serious problem...
>
> []s
> Edson
Thanks, Edson. I think that recompilation may be the problem; I'm creating
the RuleBase in a @PostConstruct method in an ejb3 stateless session bean,
and it looks like if multiple instances of the session bean are added to the
pool the rule base is compiled multiple times. So, how to get around this
problem? In another thread you said:
> Also, usage of statics is not always good, specially if you intent to run
your application in a JEE environment.
so I presume that using a regular old singleton to share the RuleBase
instance is not a good idea. Is there any approach you can suggest that will
avoid using statics? This app is running under Glassfish.
Thanks for your help,
Kris
>
>
> 2008/11/26 Kris Nuttycombe <kris.nuttycombe(a)gmail.com>
>
>> Hi, all,
>>
>> I'm encountering significant problems with running out of memory when
>> executing a small ruleset (only 16 rules, < 100 facts). I've run jmap on
the
>> process (which has previously spawned multiple stateless sessions in
>> parallel) and it looks like Drools, and specifically the Eclipse jdt
>> compiler, is seriously eating up memory. The code calling the is fairly
>> simple; one of the initial facts is an accumulator that I refer to later:
>>
>> StatelessSession session = ruleBase.newStatelessSession();
>> session.execute(initialFact, accumulator);
>>
>> accumulator.doSomething();
>>
>> where ruleBase is a shared instance, and initialFact is a base fact that
>> is expanded during rules processing. Is there something I should be doing to
>> dispose the session after use to release the objects created by the drools
>> compiler after use? I'm using a shared RuleBase, and I'm wondering
whether
>> it is somehow keeping references around. Are these sorts of object counts to
>> be expected?
>>
>> Thanks,
>>
>> Kris
>> Instance Counts for All Classes (excluding platform) 104827
instances<http://carrot.gaiam.com:7000/instances/0x2aaacf5646f8>of class
>>
net.jxta.impl.document.LiteXMLElement$charRange<http://carrot.gaiam.com:7000/class/0x2aaacf5646f8>
>> 26806 instances <
http://carrot.gaiam.com:7000/instances/0x2aaacf5631e8>of
class
>>
net.jxta.impl.document.LiteXMLElement$tagRange<http://carrot.gaiam.com:7000/class/0x2aaacf5631e8>
>> 26733 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad66ea7f0>of
class
>>
org.eclipse.jdt.internal.compiler.lookup.MethodBinding<http://carrot.gaiam.com:7000/class/0x2aaad66ea7f0>
>> 17366 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad66e3c88>of
class
>>
[Lorg.eclipse.jdt.internal.compiler.lookup.TypeBinding;<http://carrot.gaiam.com:7000/class/0x2aaad66e3c88>
>> 12412 instances <
http://carrot.gaiam.com:7000/instances/0x2aaacf032560>of
class
>>
com.sun.enterprise.loader.EJBClassLoader$SentinelInputStream<http://carrot.gaiam.com:7000/class/0x2aaacf032560>
>> 10974 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad5504450>of
class
>>
org.apache.commons.collections.SequencedHashMap$Entry<http://carrot.gaiam.com:7000/class/0x2aaad5504450>
>> 8683 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad68c3840>of
class
>>
org.eclipse.jdt.internal.compiler.codegen.CachedIndexEntry<http://carrot.gaiam.com:7000/class/0x2aaad68c3840>
>> 7708 instances <
http://carrot.gaiam.com:7000/instances/0x2aaacf55e9d8>of
class
>>
net.jxta.impl.document.LiteXMLElement<http://carrot.gaiam.com:7000/class/0x2aaacf55e9d8>
>> 7450 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad5c4b6c0>of
class
>>
org.hibernate.engine.CollectionKey<http://carrot.gaiam.com:7000/class/0x2aaad5c4b6c0>
>> 6836 instances <
http://carrot.gaiam.com:7000/instances/0x2aaaced3c3f8>of
class
>>
org.netbeans.modules.schema2beans.AttrProp<http://carrot.gaiam.com:7000/class/0x2aaaced3c3f8>
>> 6271 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad6642d18>of
class
>>
org.eclipse.jdt.internal.compiler.lookup.FieldBinding<http://carrot.gaiam.com:7000/class/0x2aaad6642d18>
>> 5643 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad6796890>of
class
>>
org.eclipse.jdt.internal.compiler.ast.MessageSend<http://carrot.gaiam.com:7000/class/0x2aaad6796890>
>> 4928 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad68a6018>of
class
>>
org.eclipse.jdt.internal.compiler.util.HashtableOfObject<http://carrot.gaiam.com:7000/class/0x2aaad68a6018>
>> 4895 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad66e3fa8>of
class
>>
[Lorg.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;<http://carrot.gaiam.com:7000/class/0x2aaad66e3fa8>
>> 4546 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad669f968>of
class
>>
org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding<http://carrot.gaiam.com:7000/class/0x2aaad669f968>
>> 4472 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad687a0a8>of
class
>>
[Lorg.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;<http://carrot.gaiam.com:7000/class/0x2aaad687a0a8>
>> 4128 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad6103ff0>of
class
>> org.drools.rule.Pattern<http://carrot.gaiam.com:7000/class/0x2aaad6103ff0>
>> 3899 instances <
http://carrot.gaiam.com:7000/instances/0x2aaacf493c90>of
class
>>
net.jxta.impl.id.UUID.UUID<http://carrot.gaiam.com:7000/class/0x2aaacf493c90>
>> 3867 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad5c416c0>of
class
>>
org.hibernate.engine.EntityEntry<http://carrot.gaiam.com:7000/class/0x2aaad5c416c0>
>> 3731 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad5c54d88>of
class
>>
org.hibernate.collection.PersistentSet<http://carrot.gaiam.com:7000/class/0x2aaad5c54d88>
>> 3685 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad66ca420>of
class
>>
org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding<http://carrot.gaiam.com:7000/class/0x2aaad66ca420>
>> 3360 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad6c12770>of
class
>>
org.drools.reteoo.SingleTupleSinkAdapter<http://carrot.gaiam.com:7000/class/0x2aaad6c12770>
>> 3266 instances <
http://carrot.gaiam.com:7000/instances/0x2aaacf543dc0>of
class
>>
net.jxta.document.MimeMediaType<http://carrot.gaiam.com:7000/class/0x2aaacf543dc0>
>> 3264 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad6370288>of
class
>>
org.drools.spi.PatternExtractor<http://carrot.gaiam.com:7000/class/0x2aaad6370288>
>> 3163 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad5f8b990>of
class
>>
org.apache.axis.encoding.TypeMappingImpl$Pair<http://carrot.gaiam.com:7000/class/0x2aaad5f8b990>
>> 3137 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad5caad98>of
class
>>
org.hibernate.collection.PersistentBag<http://carrot.gaiam.com:7000/class/0x2aaad5caad98>
>> 2881 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad681b000>of
class
>>
org.eclipse.jdt.internal.compiler.lookup.MethodScope<http://carrot.gaiam.com:7000/class/0x2aaad681b000>
>> 2688 instances <
http://carrot.gaiam.com:7000/instances/0x2aaad6161860>of
class
>>
org.drools.base.ClassFieldExtractor<http://carrot.gaiam.com:7000/class/0x2aaad6161860>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @