I am currently running version 5.1.0M2. I have 18 different binary
rulesets [packages] that are stored on the local filesystem. The
rulesets range in size from 4K to 131Mb.
When my application starts I load each ruleset into a knowledgeAgent and
store the knowledgeAgent into a hashmap which is stored in memory.
They are loaded using the following xml:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<change-set
xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set.xsd'>
<add>
<resource source='file://PATH_TO_BINARY' type='PKG' />
</add>
</change-set>
The knowledgeAgentConfiguration is setup as:
drools.agent.scanDirectories = false
drools.agent.newInstance = false
drools.agent.scanResources = false
drools.agent.monitorChangeEvents = false
After the all the agents are loaded and stored in the hashmap the total
memory used in the app is 6.2GB.
Once the application is running, if a business user needs to update a
set of rules there is a process in place to refresh all the
knowledgeAgents with new rulesets. In a new thread. the code clears the
hashmap, sets the hashmap to null, calls for garbage collection to
occur, and it then constructs a new hashmap and loads all the rules as
it does at application startup.
The knowledge agent is logging the following when the ruleset is loaded:
KnowledgeAgent applying ChangeSet
KnowledgeAgent performing an incremental build of the ChangeSet
KnowledgeAgent incremental build of KnowledgeBase finished and in use
It takes a large amount of time to do this process [double to triple the
time of application startup]. After this occurs the memory used by the
app increases [to nearly double the original size 12.2GB] and the CPU is
maxed out. After some time the CPU usage drops and the app is usable
again but the memory never decreases. If a business user refreshes the
rules again, the memory increases again and the CPU is maxed out and the
app becomes unresponsive because the memory is completely maxed out.
There is obviously a memory leak somewhere and a large one at that. Is
this the proper way to be caching KnowledgeAgents into memory so the
rulessets don't need to be re-loaded everytime a knowledgeAgent is run?
Is my problem the use of the hashmap? Do I need to remove the original
knowledgeAgents that were in the hashmap?
Thanks for any help.