Hmm, let me complement Wolfgang's comment:

> After you have taken the compiled packages from the KB and checked for errors, the KB has done his duty the KB ****MUST**** go :-)

   The above emphasis is mine. KnowledgeBuilder is a higher level object designed to encapsulate the parsing+compilation steps of resources. It is **not** designed to be reused and doing so might create inconsistencies. The memory spike you see when using the kbuilder is due to the java compiler... Drools itself does not do anything fancy in there other than generate some code (quite inexpensive memory wise) and compile it using either JDT or JANINO (both quite expensive memory wise, when compared to the other steps).

   So, I strongly discourage you keeping the KB around and as mentioned by Wolfgang, doing so might keep unnecessary objects in memory.

   Also, just to clarify, deserializing a compiled package means the compiler will not be called (obviously, as everything is already compiled) and that is why it should save you memory.

   Edson

2010/4/1 Wolfgang Laun <wolfgang.laun@gmail.com>
2010/4/1 miguel machado <mls.machado@gmail.com>:
>
> 2010/3/31 Edson Tirelli <ed.tirelli@gmail.com>
>>
>> 1. Do you use one KnowledgeBuilder to compile all your rule files or do
>> you use one KnowledgeBuilder per file?
>
> Just one, declared as a static variable.

That wastes, whatever the KB takes, for the remaining duration of the program
execution. After you have taken the compiled packages from the KB and
checked for errors, the KB has done his duty the KB can go :-)


>>
>> 5. Did you tried compiling it once, generating the kbase and serializing
>> it to a file, and then, instead of recompiling everything, just deserialize
>> the file into memory and using it? How much memory it consumes when you
>> deserialize from a file?
>
> Not sure what you mean there, is it
> this: http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e1070 ?
> if so, yes, i've tried it and noticed no difference at all, was i supposed
> to?

For the application that just does the load part (reading the KPs from
an input stream), yes: that
should reduce memory usage.

It certainly does not, if your KB is static, and you compile and load
in the same program,
just serializing and deserializing in between.

-W

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



--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com