[rules-users] Potential memory problems

Matthew Shaw mshaw at emergency.qld.gov.au
Tue Apr 24 00:55:37 EDT 2007


Hi Ron,
 
yes I do create a new working memory each time. In the middle of testing the change, I'll let you know the outcome.
 
Cheers,
Matt.

________________________________

From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Ronald R. DiFrango
Sent: Tuesday, 24 April 2007 4:25 AM
To: Rules Users List
Subject: Re: [rules-users] Potential memory problems


Matt,

I am sure that would work, but I wonder are you building a new working memory each time as well?  If not then maybe you should.  My methods always look something like the following:

{
    final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
    // Assert my objects
    workingMemory.assertObject(object);
    // Fire the rules
    workingMemory.fireAllRules();
    // Return what ever you need to
    return result; 
}

That way WorkingMemory is thrown away each time.  Also, it is fairly low overhead to create one each time.  Especially given that you clear and dispose each.

Ron


On 4/23/07, Matthew Shaw <mshaw at emergency.qld.gov.au> wrote: 

	Hi, 

	I am fronting my rule engine by a stateless session façade bean, running in a weblogic container. The rule bases are loaded only once via a singleton. 

	I was running a profiler over the app and have noticed a lot of rule engine objects still attached to the tree. My stub which invokes the working memory looks like the following: 

	try { 
	        handle = wm.assertObject(shift); 
	        wm.assertObject(shiftCalculator); 
	        wm.fireAllRules(); 
	} catch (RuntimeDroolsException e) { 
	        throw new TimesheetServiceUnavailableException( 
	                                        "Could not add shift to Working Memory", e); 
	} 
	wm.clearAgenda(); 
	wm.dispose(); 
	LoggingUtils.logMethodFinish(logger, methodName); 

	As you can see if an exception occurs then the dispose method is not run. Could this lead to memory leakage? 

	I have subsequently modified the offending stub to include a finally block 

	finally { 
	        wm.clearAgenda(); 
	        wm.dispose(); 
	        LoggingUtils.logMethodFinish( logger, methodName); 
	} 

	Matt Shaw 
	Snr Applications Developer 
	Service Performance & Management Unit 
	Phone: 3247 8666. ext. 94666 

This correspondence is for the named persons only. 
It may contain confidential or privileged information or both. 
No confidentiality or privilege is waived or lost by any mis transmission. 
If you receive this correspondence in error please delete it from your system immediately and notify the sender. 
You must not disclose, copy or relay on any part of this correspondence, if you are not the intended recipient. 
Any opinions expressed in this message are those of the individual sender except where the sender expressly, 
and with the authority, states them to be the opinions of the Department of Emergency Services, Queensland.
	

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




This correspondence is for the named persons only. 
It may contain confidential or privileged information or both. 
No confidentiality or privilege is waived or lost by any mis transmission. 
If you receive this correspondence in error please delete it from your system immediately and notify the sender. 
You must not disclose, copy or relay on any part of this correspondence, if you are not the intended recipient. 
Any opinions expressed in this message are those of the individual sender except where the sender expressly, 
and with the authority, states them to be the opinions of the Department of Emergency Services, Queensland.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070424/50aed209/attachment.html 


More information about the rules-users mailing list