[JBoss jBPM] - Is this a mem. leak
by Johan.Parent
Hi all,
As a test I have wrapped up the Websale demo code in a loop. In the loop a process is instantiated (one at a time) and the different tasks are handled (See fullCycle() in code below).
Initially one iteration takes 0.2 secs (not too fast...) but performance drops after a while.
After some 4000 iterations the process consumes 256+Mb of mem (and with my jvm settings) slows down to a crawl. As far as I can see the jvm spends most of its time doing "stop the world" gc's.
I put the code below. Can anyone take the code and try to reproduce the drop in performance and/or increasing mem. consumption?
Note you'll need a few more files which come with the starters kit.
Regards,
Johan
| package JBpmTest;
|
| /**
| * Created by IntelliJ IDEA.
| * User: jparent
| * Date: 15-jan-2007
| * Time: 13:26:08
| * To change this template use File | Settings | File Templates.
| */
| public class MainWebsaleTest {
| static public void main(String[] args) {
| WebsaleTest sale = new WebsaleTest();
| int loops[] = { 5000 };
| JBpmTiming timer = new JBpmTiming("global");
| JBpmTiming one = new JBpmTiming("single");
|
| try {
| sale.setUp();
|
| for (int count = 0; count<loops.length; count++) {
| System.out.println("Number of loops " + loops[count]);
|
| timer.reset();
| timer.start();
| for (int i = 0; i<loops[count]; i++) {
| one.reset();
| one.start();
| sale.fullCycle();
| System.out.println(i + " " + one.stop());
| }
|
| timer.stop();
| System.out.println("Number of loops " + loops[count]);
| timer.print();
| }
|
| sale.tearDown();
| }
| catch(Exception e) {
| e.printStackTrace();
| }
| }
| }
|
The slightly MODIFIED Websale
| package JBpmTest;
|
| /**
| * Created by IntelliJ IDEA.
| * User: jparent
| * Date: 15-jan-2007
| * Time: 13:00:29
| * To change this template use File | Settings | File Templates.
| */
| /*
| public class WebsaleTest {
| }
| */
|
|
| import java.util.HashMap;
| import java.util.List;
| import java.util.Map;
|
| import org.jbpm.JbpmConfiguration;
| import org.jbpm.context.exe.ContextInstance;
| import org.jbpm.db.AbstractDbTestCase;
| import org.jbpm.graph.def.ProcessDefinition;
| import org.jbpm.graph.exe.ProcessInstance;
| import org.jbpm.identity.Entity;
| import org.jbpm.identity.hibernate.IdentitySession;
| import org.jbpm.identity.xml.IdentityXmlParser;
| import org.jbpm.taskmgmt.exe.TaskInstance;
| import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
|
| public class WebsaleTest extends AbstractDbTestCase {
|
| JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
|
| ProcessDefinition processDefinition = null;
| ProcessInstance processInstance = null;
| ContextInstance contextInstance = null;
| TaskMgmtInstance taskMgmtInstance = null;
| long processInstanceId = -1;
|
| boolean doUnitTest = false;
|
| public void setUp() throws Exception {
| super.setUp();
| deployProcess();
| loadIdentities();
| newTransaction();
| }
|
| private void deployProcess() {
| ProcessDefinition processDefinition =
| ProcessDefinition.parseXmlResource("websale.par/processdefinition.xml");
| jbpmContext.deployProcessDefinition(processDefinition);
| }
|
| private void loadIdentities() {
| // load the identities
| Entity[] entities = IdentityXmlParser.parseEntitiesResource("hsqldb/identity.db.xml");
| IdentitySession identitySession = new IdentitySession(session);
| for (int i=0; i<entities.length; i++) {
| identitySession.saveEntity(entities);
| }
| newTransaction();
| }
|
| private void createNewProcessInstance() {
| processDefinition = graphSession.findLatestProcessDefinition("websale");
| processInstance = new ProcessInstance(processDefinition);
| contextInstance = processInstance.getContextInstance();
| taskMgmtInstance = processInstance.getTaskMgmtInstance();
| }
|
|
| public void testWebSaleOrderTaskParameters() {
| TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
| assertEquals("create new web sale order", taskInstance.getName());
| assertEquals(0, taskInstance.getVariables().size());
| }
|
| public void testPerformWebSaleOrderTask() {
| TaskInstance taskInstance = null;
|
| jbpmContext.setActorId("cookie monster");
| // create a task to start the websale process
| taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
|
| Map taskVariables = new HashMap();
| taskVariables.put("item", "cookies");
| taskVariables.put("quantity", "lots of them");
| taskVariables.put("address", "sesamestreet 46");
|
| taskInstance.addVariables(taskVariables);
| taskInstance.end();
|
| assertEquals("cookies", contextInstance.getVariable("item"));
| assertEquals("lots of them", contextInstance.getVariable("quantity"));
| assertEquals("sesamestreet 46", contextInstance.getVariable("address"));
| assertEquals("cookie monster", taskMgmtInstance.getSwimlaneInstance("buyer").getActorId());
| }
|
| public void testEvaluateAssignment() {
| TaskInstance taskInstance = null;
|
| jbpmContext.setActorId("cookie monster");
| // create a task to start the websale process
| taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
| taskInstance.setVariable("item", "cookies");
| taskInstance.end();
| jbpmContext.save(processInstance);
| processInstanceId = processInstance.getId();
|
| newTransaction();
|
| List erniesTasks = taskMgmtSession.findTaskInstances("ernie");
| assertEquals(1, erniesTasks.size());
|
| TaskInstance evaluateTaskInstance = (TaskInstance) erniesTasks.get(0);
| assertEquals("ernie", evaluateTaskInstance.getActorId());
| assertEquals("evaluate web order", evaluateTaskInstance.getName());
| assertNotNull(evaluateTaskInstance.getToken());
| assertNotNull(evaluateTaskInstance.getCreate());
| assertNull(evaluateTaskInstance.getStart());
| assertNull(evaluateTaskInstance.getEnd());
| }
|
| public void testEvaluateOk() {
| TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
| taskInstance.end();
| jbpmContext.save(processInstance);
|
| newTransaction();
|
| TaskInstance evaluateTaskInstance = (TaskInstance) taskMgmtSession.findTaskInstances("ernie").get(0);
| evaluateTaskInstance.end("ok");
| jbpmContext.save(evaluateTaskInstance);
|
| newTransaction();
|
| List erniesTasks = taskMgmtSession.findTaskInstances("bert");
| assertEquals(1, erniesTasks.size());
|
| TaskInstance waitForMoneyTaskInstance = (TaskInstance) erniesTasks.get(0);
| assertEquals("bert", waitForMoneyTaskInstance.getActorId());
| assertEquals("wait for money", waitForMoneyTaskInstance.getName());
| assertNotNull(waitForMoneyTaskInstance.getToken());
| assertNotNull(waitForMoneyTaskInstance.getCreate());
| assertNull(waitForMoneyTaskInstance.getStart());
| assertNull(waitForMoneyTaskInstance.getEnd());
| }
|
| public void testUnwritableVariableException() {
| testEvaluateAssignment();
| newTransaction();
| List erniesTasks = taskMgmtSession.findTaskInstances("ernie");
| TaskInstance evaluateTaskInstance = (TaskInstance) erniesTasks.get(0);
| // this variable is set in the task instance variables, but
| // should not be submitted to the process context variables.
| evaluateTaskInstance.setVariable("item", "this is not allowed");
| evaluateTaskInstance.end();
|
| newTransaction();
|
| processInstance = graphSession.loadProcessInstance(processInstanceId);
| contextInstance = processInstance.getContextInstance();
| // so the cookies should still be in the item process variable.
| assertEquals("cookies", contextInstance.getVariable("item"));
| }
|
| public void testEvaluateNok() {
| testEvaluateAssignment();
| newTransaction();
|
| List erniesTasks = taskMgmtSession.findTaskInstances("ernie");
| TaskInstance evaluateTaskInstance = (TaskInstance) erniesTasks.get(0);
| evaluateTaskInstance.setVariable("comment", "wtf");
| evaluateTaskInstance.end("more info needed");
| jbpmContext.save(evaluateTaskInstance);
|
| newTransaction();
|
| List cookieMonsterTasks = taskMgmtSession.findTaskInstances("cookie monster");
| assertEquals(1, cookieMonsterTasks.size());
| TaskInstance fixWebOrderDataTaskInstance = (TaskInstance) cookieMonsterTasks.get(0);
| assertEquals("cookie monster", fixWebOrderDataTaskInstance.getActorId());
| assertEquals("wtf", fixWebOrderDataTaskInstance.getVariable("comment"));
| }
|
| public void testMoreInfoNeeded() {
| TaskInstance taskInstance = null;
|
| jbpmContext.setActorId("cookie monster");
|
| // create a task to start the websale process
| taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
| taskInstance.end();
| jbpmContext.save(processInstance);
|
| newTransaction();
|
| TaskInstance evaluateTaskInstance = (TaskInstance) taskMgmtSession.findTaskInstances("ernie").get(0);
| evaluateTaskInstance.end("more info needed");
| jbpmContext.save(evaluateTaskInstance);
|
| newTransaction();
|
| List cookieMonsterTasks = taskMgmtSession.findTaskInstances("cookie monster");
| assertEquals(1, cookieMonsterTasks.size());
|
| TaskInstance fixWebOrderDataTaskInstance = (TaskInstance) cookieMonsterTasks.get(0);
| assertEquals("cookie monster", fixWebOrderDataTaskInstance.getActorId());
| assertEquals("fix web order data", fixWebOrderDataTaskInstance.getName());
| assertNotNull(fixWebOrderDataTaskInstance.getToken());
| assertNotNull(fixWebOrderDataTaskInstance.getCreate());
| assertNull(fixWebOrderDataTaskInstance.getStart());
| assertNull(fixWebOrderDataTaskInstance.getEnd());
| }
|
| public void fullCycle() {
| createNewProcessInstance();
|
| TaskInstance taskInstance = null;
|
| jbpmContext.setActorId("cookie monster");
| // create a task to start the websale process
| taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
| taskInstance.setVariable("item", "cookies");
| taskInstance.end();
| jbpmContext.save(processInstance);
| processInstanceId = processInstance.getId();
|
| newTransaction();
|
| List erniesTasks = taskMgmtSession.findTaskInstances("ernie");
|
| if (doUnitTest)
| assertEquals(1, erniesTasks.size());
|
| if (erniesTasks.size() > 0) {
| TaskInstance evaluateTaskInstance = (TaskInstance) erniesTasks.get(0);
|
| if (doUnitTest) {
| assertEquals("ernie", evaluateTaskInstance.getActorId());
| assertEquals("evaluate web order", evaluateTaskInstance.getName());
| assertNotNull(evaluateTaskInstance.getToken());
| assertNotNull(evaluateTaskInstance.getCreate());
| assertNull(evaluateTaskInstance.getStart());
| assertNull(evaluateTaskInstance.getEnd());
| }
| }
| newTransaction();
|
| erniesTasks = taskMgmtSession.findTaskInstances("ernie");
| if (erniesTasks.size() > 0) {
| TaskInstance evaluateTaskInstance = (TaskInstance) erniesTasks.get(0);
| evaluateTaskInstance.setVariable("comment", "wtf");
| evaluateTaskInstance.end("more info needed");
| jbpmContext.save(evaluateTaskInstance);
| }
|
| newTransaction();
|
| List cookieMonsterTasks = taskMgmtSession.findTaskInstances("cookie monster");
| if (doUnitTest)
| assertEquals(1, cookieMonsterTasks.size());
|
| if (cookieMonsterTasks.size() > 0) {
| TaskInstance fixWebOrderDataTaskInstance = (TaskInstance) cookieMonsterTasks.get(0);
| if (doUnitTest) {
| assertEquals("cookie monster", fixWebOrderDataTaskInstance.getActorId());
| assertEquals("wtf", fixWebOrderDataTaskInstance.getVariable("comment"));
| }
|
| fixWebOrderDataTaskInstance.end();
| }
|
| newTransaction();
|
| erniesTasks = taskMgmtSession.findTaskInstances("ernie");
|
| if (erniesTasks.size() > 0) {
| TaskInstance evaluateTaskInstance = (TaskInstance) erniesTasks.get(0);
| evaluateTaskInstance.setVariable("comment", "IS OK NOW");
| evaluateTaskInstance.end("ok");
| jbpmContext.save(evaluateTaskInstance);
| }
|
| newTransaction();
|
| List bertTasks = taskMgmtSession.findTaskInstances("bert");
| if (doUnitTest)
| assertEquals(1, bertTasks.size());
|
| if (bertTasks.size() > 0) {
| TaskInstance waitForMoneyTaskInstance = (TaskInstance) bertTasks.get(0);
| if (doUnitTest) {
| assertEquals("bert", waitForMoneyTaskInstance.getActorId());
| assertEquals("wait for money", waitForMoneyTaskInstance.getName());
| assertNotNull(waitForMoneyTaskInstance.getToken());
| assertNotNull(waitForMoneyTaskInstance.getCreate());
| assertNull(waitForMoneyTaskInstance.getStart());
| assertNull(waitForMoneyTaskInstance.getEnd());
| }
|
| waitForMoneyTaskInstance.end();
| }
|
| List groverTasks = taskMgmtSession.findTaskInstances("grover");
| if (doUnitTest)
| assertEquals(1, groverTasks.size());
|
| if (groverTasks.size() > 0) {
| TaskInstance shippingTask = (TaskInstance) groverTasks.get(0);
| shippingTask.end();
| }
|
| // Setup new session & co for next loop (not inside this method)
| newTransaction();
| }
| }
|
And the timing utility
| package JBpmTest;
|
| /**
| * Created by IntelliJ IDEA.
| * User: jparent
| * Date: 19-dec-2006
| * Time: 10:50:59
| * To change this template use File | Settings | File Templates.
| */
| public class JBpmTiming {
| private long total;
| private long min, max;
| private long count;
| private long start_time;
| String label;
|
| public JBpmTiming(String l) {
| reset();
| count = 0;
| min = 100000L;
| max = -1000000L;
| label = l;
| }
|
| public JBpmTiming() {
| this("Unknown");
| }
|
| public void start() {
| count++;
| start_time = System.currentTimeMillis ();
| }
|
| public long stop() {
| long ret = System.currentTimeMillis () - start_time ;
| total += ret;
|
| if (ret > max)
| max = ret;
|
| if (ret < min)
| min = ret;
|
| return ret;
| }
|
| public void accumulate(JBpmTiming in) {
| total += in.total;
| count += in.count;
|
| if (in.max > max)
| max = in.max;
|
| if (in.min < min)
| min = in.min;
| }
|
| void reset() {
| total = 0;
| count = 0;
| }
|
| public void print() {
| System.out.println("Name: " + label + " " + total+ "/" + min + "/" + max + "[" + total / (double)count + "|" + count + "] (tot/min/max[avg|nbr])");
| }
| }
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4003393#4003393
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4003393
19 years, 3 months
[JBossCache] - Re: Problem running PojoCache in JBoss AS
by jcollins914
I don't know why the forum represses xml-information if you don't wrap it in a code tag, but I've pasted the various bits here for completeness...
============================
============================
Code under step 8:
<mbean code="org.jboss.cache.aop.PojoCache" name="jboss.cache:service=PojoCache">
Code under step 10:
| <aop>
| <prepare expr="field(* @org.jboss.cache.aop.annotation.PojoCacheable->*)" />
| </aop>
|
ant build bits referred to in question 1:
| <fileset dir="${cache.lib}">
| <include name="**/*.jar" />
| <exclude name="jboss-cache.jar" />
| <exclude name="jboss-aop.jar" />
| </fileset>
|
| <fileset dir="${cache.lib-50}">
| <include name="**/*.jar" />
| </fileset>
|
|
| <path id="pojocache.lib.classpath">
| <fileset dir="${cache.lib}">
| <include name="jboss-common.jar" />
| <include name="concurrent.jar" />
| <include name="javassist.jar" />
| <include name="trove.jar" />
| </fileset>
| <fileset dir="${cache.lib-50}">
| <include name="jboss-cache-jdk50.jar" />
| <include name="jboss-aop-jdk50.jar" />
| </fileset>
| </path>
|
|
| <target name="aopc" description="Precompile aop test classes" depends="copyclasses">
| <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="pojocache.lib.classpath" />
|
| <aopc compilerclasspathref="lib.classpath" verbose="true">
| <classpath path="${aop.class.dir}"/>
| <src path="${aop.class.dir}" />
| <!-- <include name="${UserInfoTEST.class}"/>
| <aoppath path="${aop.path}"/> -->
| <aopclasspath path="${aop.class.dir}"/>
| </aopc>
|
| </target>
|
details from question 2:
instead of as follows:
| <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar" />
|
it would appear as follows:
| <classpath codebase="./lib" archives="jboss-cache-jdk50.jar, jgroups.jar" />
|
Thanks,
Jeff
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4003391#4003391
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4003391
19 years, 3 months
[JBoss Portal] - Re: Refreshing a portlet's cache
by nollie
Unfortunately, no I didn't find a good way to do this. At one point I had my scheduler bean running but I hadn't figured out how to be sure that it was using the same classloader as my portlet.
Since my cache refresh was under 10 seconds we decided to let one user per day take the 'hit' and table the issue. In the future when we are using EJBs I'll revisit this.
Here is a very simple timer example:
CacheDumpScheduler.java:
package com.foo;
|
| import java.util.Date;
|
| import org.jboss.varia.scheduler.Schedulable;
|
| public class CacheDumpScheduler implements Schedulable {
|
| public void perform(Date now, long remainingRepetitions) {
| MyPortlet.resetCache();
|
| }
|
|
| }
META-INF/jboss-service.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <server>
| <mbean code="org.jboss.varia.scheduler.Scheduler" name="com.foo:service=CacheDumpScheduler">
| <attribute name="StartAtStartup">true</attribute>
| <attribute name="SchedulableClass">
| com.foo.CacheDumpScheduler
| </attribute>
| <attribute name="SchedulableArguments">
| </attribute>
| <attribute name="SchedulableArgumentTypes">
| </attribute>
| <attribute name="InitialStartDate">NOW</attribute>
| <attribute name="SchedulePeriod">6000</attribute>
| <attribute name="InitialRepetitions">-1</attribute>
| <depends>jboss.web:service=WebServer</depends>
| </mbean>
|
| </server>
Hope that helps
Jon
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4003389#4003389
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4003389
19 years, 3 months
[EJB/JBoss] - Re: Stack Overflow using EJB3
by tarantula
Hey guys,
Looks like this is still an issue for EJB3 / JBoss 4.0.5 GA.
Not sure why, the EJB3 spec clearly says (emphasis added):
4.2.1 Instance Passivation and Conversational State
|
| The Bean Provider is required to ensure that the PrePassivate method leaves the instance fields and the fields of its associated interceptors ready to be serialized by the container. The objects that are assigned to the instance?s non-transient fields and the non-transient fields of its interceptors after the PrePassivate method completes must be one of the following.
|
| - A serializable object.
| - A null.
| - A reference to an enterprise bean?s business interface.
| - A reference to an enterprise bean?s remote interface, even if the stub class is not serializable.
| - A reference to an enterprise bean?s remote home interface, even if the stub class is not serializable.
| - A reference to an entity bean?s local interface, even if it is not serializable.
| - A reference to an entity bean?s local home interface, even if it is not serializable.
| - A reference to the SessionContext object, even if it is not serializable.
| - A reference to the environment naming context (that is, the java:comp/env JNDI context)
| or any of its subcontexts.
| - A reference to the UserTransaction interface.
| - A reference to a resource manager connection factory.
| - A reference to a container-managed EntityManager object, even if it is not serializable.
|
| ...
|
I'm seeing a lot of stack traces during SFSB passivation, but most of the time the app server just hangs.
The transient SessionContext did not work for me. Not sure what the problem is.
Hmm...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4003383#4003383
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4003383
19 years, 3 months