Re: [rules-users] ArrayIndexOutOfBounds when calling addKnowledgePackage?

2010-05-24 Thread malkhafaji

Yes. Actually that is exactly what I did, but I wanted to test something out
in the process and I decided to try it like that. But in any case, I am
using your line instead. I wrote the disclaimer in the email I sent with the
code :)

On Mon, May 24, 2010 at 12:59 AM, Wolfgang Laun-2 [via Drools - Java Rules
Engine] 
ml-node+838997-848786506-94...@n3.nabble.comml-node%2b838997-848786506-94...@n3.nabble.com
 wrote:

 On 23 May 2010 15:31, malkhafaji [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=838997i=0
  wrote:


 Hello,

 I am trying to create a bunch of KnowledgeBase objects, this is what I am
 doing:

 1. create one List of KnowledgePackage objects (pre-compile them).
 2. Create X number of KnowledgeBases, and for each knowledge base do this:

 for (KnowledgePackage kp : this.knowledgePackages) {
CollectionKnowledgePackage collections =
 new
 ArrayListKnowledgePackage();
collections.add(kp);

  knowledgeBase.addKnowledgePackages(collections);
}


 This is a very circumstantial way of doing

knowledgeBase.addKnowledgePackages( this.knowledgePackages );

 -W

 ___
 rules-users mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=838997i=1
 https://lists.jboss.org/mailman/listinfo/rules-users


 --
  View message @
 http://drools-java-rules-engine.46999.n3.nabble.com/ArrayIndexOutOfBounds-when-calling-addKnowledgePackage-tp837841p838997.html
 To unsubscribe from ArrayIndexOutOfBounds when calling
 addKnowledgePackage?, click 
 herehttp://drools-java-rules-engine.46999.n3.nabble.com/subscriptions/Unsubscribe.jtp?code=bW9lLmFsa2hhZmFqaUBtZWRjcHUuY29tfDgzNzg0MXwtMTQyNzk2NjgzMQ==.




-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/ArrayIndexOutOfBounds-when-calling-addKnowledgePackage-tp837841p839339.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


Re: [rules-users] ArrayIndexOutOfBounds when calling addKnowledgePackage?

2010-05-23 Thread malkhafaji

And for the same isolated test, but in a different run, I also get this
(exactly at the same line):

P.S. I was just trying to create 7 KnowledgeBase instances. I am also
running with a huge perm memory setting: -XX:PermSize=128m
-XX:MaxPermSize=672

Exception in thread main java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at
org.drools.rule.JavaDialectRuntimeData$PackageClassLoader.fastFindCla
ss(JavaDialectRuntimeData.java:440)
at
org.drools.rule.CompositeClassLoader.fastFindClass(CompositeClassLoad
er.java:53)
at
org.drools.rule.CompositeClassLoader.loadClass(CompositeClassLoader.j
ava:68)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
org.drools.rule.JavaDialectRuntimeData.wire(JavaDialectRuntimeData.ja
va:306)
at
org.drools.rule.JavaDialectRuntimeData.wire(JavaDialectRuntimeData.ja
va:297)
at
org.drools.rule.JavaDialectRuntimeData.onBeforeExecute(JavaDialectRun
timeData.java:143)
at
org.drools.rule.DialectRuntimeRegistry.onBeforeExecute(DialectRuntime
Registry.java:114)
at
org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:
481)
at
org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:426)

at
org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseI
mpl.java:121)
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/ArrayIndexOutOfBounds-when-calling-addKnowledgePackage-tp837841p837849.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


Re: [rules-users] ArrayIndexOutOfBounds when calling addKnowledgePackage?

2010-05-23 Thread malkhafaji

Additional information. When I removed the threads (everything executing
sequentially), I got rid of the first problem above which is the index out
of bounds exception. However, I am consistently getting the perm gen out of
memory exception although I have plenty of it.

So, I decided to create those 7 instances of KnowledgeBase objects and not
save them in memory (leave them eligible for GC) and I was able to get up to
20 instances created. When I added the statement that adds every newly
created KnowledgeBase to an existing array list, that is when I got the
memory exception again at around 5/6 KnowledgeBase.

If I try to create KnowledgeBase instances WITHOUT adding KnowledgePackages
to it (I am adding a total of 6), then I can create all KnowledgeBase
successfully.

I even created a whole new KnolwedgePackage array list from scratch on every
creation of KnowledgeBase just to isolate any potential problems due to
sharing of the array list among the newly created KnowledgeBases, and the
issue remains the same (memory error).

So, it is not the sharing of the array list of KnowledgePackage instances,
it is not the fact that I am creating multiple KnowledgeBases in memory. It
is the fact that I am creating multiple instances of KnowledgeBase objects
AND adding 6 KnowledgePackage objects to each one. I max out at around 5/6
and then it fails.

Here is the last run that failed (I printed out Runtime...freeMemory() and
availableMemory()):
Free memory: 45 MB
Available memory: 254 MB

Then the exception right when I wanted to add KP array list to the next
KnowledgeBase.
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/ArrayIndexOutOfBounds-when-calling-addKnowledgePackage-tp837841p837886.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


Re: [rules-users] ArrayIndexOutOfBounds when calling addKnowledgePackage?

2010-05-23 Thread malkhafaji

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


Re: [rules-users] ArrayIndexOutOfBounds when calling addKnowledgePackage?

2010-05-23 Thread Wolfgang Laun
On 23 May 2010 15:31, malkhafaji moe.alkhaf...@medcpu.com wrote:


 Hello,

 I am trying to create a bunch of KnowledgeBase objects, this is what I am
 doing:

 1. create one List of KnowledgePackage objects (pre-compile them).
 2. Create X number of KnowledgeBases, and for each knowledge base do this:

 for (KnowledgePackage kp : this.knowledgePackages) {
CollectionKnowledgePackage collections =
 new
 ArrayListKnowledgePackage();
collections.add(kp);

  knowledgeBase.addKnowledgePackages(collections);
}


This is a very circumstantial way of doing

   knowledgeBase.addKnowledgePackages( this.knowledgePackages );

-W
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users