For those that are interested. I solved the problem. Basically I got over the following inherent problems in Drools (not that they are bugs, but they did not suit my application requirements):
1. A new class loader for each KnowledgeBase. This caused about 20-30K classes loaded per KnowledgeBase causing me the Perm gen errors. If I increased the Perm gen memory parameters, I got hit on the native thread creation issue (the more memory your application consumes, the less threads you can instantiate because you will have less memory to work with). 2. The time taken to compile the KnowledgePackages AND to add them to each KnowledgeBase. So, what I did was a combination of a few things: 1. I created one KnowledgeBase and loaded all the KnowledgePackages that I needed to load in it. Serialized it to a file. And retrieved X instances and added them to a pool. Now, I have X KnowledgeBase instances without the heavy class loading that comes with creating each one if you use the regular way of creating it from scratch. When you de-serialize it, there are a lot less classes loaded. Doing this also allowed me to avoid compiling the KnowledgePackages on start up, and now my application starts up immediately like a bullet :) 2. I changed some of my JVM parameters to add very aggressive GC parameters. The fact that I was able to avoid using many class loaders for each instantiation of a KnowledgeBase allowed me to reduce the Perm Gen memory setting which allowed me more memory for my threads :) my application is actually thread heavy, and why not when we have an 8-core server!! I am using the following JVM parameters for anyone interested: -XX:+CMSClassUnloadingEnabled -XX:+UseParallelOldGC -XX:ParallelGCThreads=8 You can look up their definitions. Now I am golden!!! -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/ArrayIndexOutOfBounds-when-calling-addKnowledgePackage-tp837841p838712.html Sent from the Drools - User mailing list archive at Nabble.com. _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users