[jbpm-dev] process instance BPMN and variable scope memory leak

Mauricio Salatino salaboy at gmail.com
Tue Jun 3 06:27:19 EDT 2014


Can you please attach a maven project? or the link to a maven project that
we can just clone from github and run?
That will give us more time to evaluate the problem, instead of wasting
time in setting up the project.


On Tue, Jun 3, 2014 at 11:13 AM, <paul.chaunguyen at externe.bnpparibas.com>
wrote:

> Hi
>
>
> *1/ Here is my snapshot code which initilize session to use bpmn:*
>
> *protected* *void* startProcess(T processContext) *throws* ProcessException
> {
>  *log*.info("Executing BPMN process : " + getProcessName().getProcessId()
> + " ...");
>  // *init* common properties when entering in process
>  init(processContext);
>
>  audit(processContext);
>
>  // process execution
>  // load up the knowledge base
>  StatefulKnowledgeSession ksession = *null*;
>
>  KnowledgeRuntimeLogger fileLogger = *null*;
>
>  String auditFileName = getAuditFileName(getProcessName(), processContext);
>  ProcessInstance processInstance = *null*;
>
>  *try* {
>  ksession = omsRulesManager.getOmsRulesService().getKnownledgeBase()
>  .newStatefulKnowledgeSession();
>
>  *if* (*log*.isDebugEnabled()) {
>  String folder = System.*getProperty*("Log4j.OUTPUT_DIR");
>
>  *if* (StringUtils.*isEmpty*(folder)) {
>  folder = System.*getProperty*("java.io.tmpdir");
>  }
>
>  String fullFileName = folder + File.*separator* + auditFileName;
>
>  fileLogger = KnowledgeRuntimeLoggerFactory.*newFileLogger*(
>  ksession, fullFileName);
>
>  ksession.addEventListener(*new* DebugWorkingMemoryEventListener());
>  ksession.addEventListener(*new* DebugAgendaEventListener());
>  }
>
>  *log*.debug("Starting workflow process : " +
> getProcessName().getProcessId()
>  + " ...");
>
>  ksession.setGlobal("log", *log*);
>
>  // populate knowledge session global
>  Map<String, Object> global = getSessionGlobal(processContext);
>  populateGlobalSession(ksession, global);
>
>  Map<String, Object> parameters = getProcessParameters(processContext);
>
>  ksession.insert((OrderContext) processContext);
>  processInstance = ksession.startProcess(getProcessName().getProcessId(),
> parameters);
>
>  ksession.insert(processInstance);
>  ksession.fireAllRules();
>
>  *if*(fileLogger != *null*) {
>  fileLogger.close();
>  }
>
>  parameters = *null*;
>  } *catch* (Exception e) {
>  *throw* *new* ProcessException(e.getMessage(), e);
>  } *finally* {
>  ksession.dispose(); // free memory
>  processInstance = *null*;
>  ksession = *null*;
>  }
>
>  *log*.info("BPMN process : " + getProcessName().name() + " executed");
>  }
>
>
>  /**
>  * Default
>  * *@param* processContext
>  * *@return*
>  */
>  @SuppressWarnings("unchecked")
>  *protected* Map<String, Object> getProcessParameters(OmsProcessContext
> processContext) {
>  Map map = *new* HashMap();
>  map.put("orderContext", (OrderContext) processContext);
>  *return* map;
>  }
>
>
> *2/ and bpmn this was very complex, I just create small one to simulate
> the case *
>
> ------ BEGIN BPMN -----
>
> <?*xml* version="1.0" encoding="UTF-8"?>
> <definitions id="Definition"
>              targetNamespace="http://www.jboss.org/drools"
>              typeLanguage="http://www.java.com/javaTypes"
>              expressionLanguage="http://www.mvel.org/2.0"
>              *xmlns*="http://www.omg.org/spec/BPMN/20100524/MODEL"
>              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>              xsi:schemaLocation="
> http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.*xsd*"
>              xmlns:g="http://www.jboss.org/drools/flow/gpd"
>              xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
>              xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
>              xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
>              xmlns:tns="http://www.jboss.org/drools">
>
>   <itemDefinition id="_orderContextItem"
> structureRef="com.bp2s.oms.process.OrderContext" />
>
>   <process processType="Private" isExecutable="true"
> id="com.bp2s.oms.dealing.process.OrderReceptionProcess"
> name="OrderReceptionProcess" tns:packageName="com.bp2s.oms.dealing.process"
> >
>
>     <extensionElements>
>      <tns:import name="com.bp2s.oms.corecontrol.ValidationResult" />
>      <tns:import
> name="com.bp2s.oms.corecontrol.service.CoreControlTreeService" />
>      <tns:import name="com.bp2s.oms.core.service.OrderService" />
>      <tns:import
> name="com.bp2s.oms.corecontrol.service.CoreControlTreeService.CoreControlTree"
> />
>      <tns:import name="com.bp2s.oms.core.error.OrderInErrorService" />
>      <tns:import name="com.bp2s.oms.model.common.OrderStatus.Status" />
>      <tns:import name="com.bp2s.oms.model.process.Disposition" />
>      <tns:import name="com.bp2s.oms.model.staticdata.Fund" />
>      <tns:import name="com.bp2s.oms.model.task.TaskContext" />
>      <tns:import name="com.bp2s.oms.process.OmsProcessContext" />
>      <tns:import name="com.bp2s.oms.process.OrderContext" />
>      <tns:import
> name="com.bp2s.oms.process.OmsProcessContext.IncomingMode" />
>      <tns:import name="com.bp2s.oms.process.OmsProcessContext.ComingFrom"
> />
>      <tns:import name="com.bp2s.oms.status.management.OrderStatusService"
> />
>      <tns:import name="com.bp2s.oms.task.TaskContextFactory" />
>      <tns:import name="com.bp2s.oms.task.TaskContextQueue" />
>      <tns:import name="com.bp2s.oms.corecontrol.CoreControlError" />
>      <tns:import name="org.apache.commons.logging.Log" />
>      <tns:import name="com.bp2s.oms.model.process.OrderInError" />
>      <tns:import name="com.bp2s.oms.model.process.Operation" />
>      <tns:import name="java.util.List" />
>      <tns:import
> name="com.bp2s.oms.corecontrol.CoreControlError.ErrorCode" />
>      <tns:import name="com.bp2s.oms.dao.StoredProcedureDAO" />
>      <tns:global identifier="queue" type="TaskContextQueue" />
>      <tns:global identifier="orderService" type="OrderService" />
>      <tns:global identifier="coreControlTreeService"
> type="CoreControlTreeService" />
>      <tns:global identifier="storedProcedureDAO" type="StoredProcedureDAO"
> />
>      <tns:global identifier="taskContextFactory" type="TaskContextFactory"
> />
>      <tns:global identifier="log" type="Log" />
>      <tns:global identifier="orderStatusService" type="OrderStatusService"
> />
>      <tns:global identifier="orderInErrorService"
> type="OrderInErrorService" />
>     </extensionElements>
>     <!-- process variables -->
>     <property id="orderContext" itemSubjectRef="_orderContextItem"/>
>
>     <!-- nodes -->
>     <startEvent id="_1" name="StartProcess" />
>     <endEvent id="_2" name="End" >
>         <terminateEventDefinition />
>     </endEvent>
>     <scriptTask id="_3" name="test parameters " scriptFormat="
> http://www.java.com/java" >
>       <script>log.info("I am here : " + orderContext.toString());</script>
>     </scriptTask>
>
>     <!-- connections -->
>     <sequenceFlow id="_3-_2" sourceRef="_3" targetRef="_2" />
>     <sequenceFlow id="_1-_3" sourceRef="_1" targetRef="_3" />
>
>   </process>
>
>   <bpmndi:BPMNDiagram>
>     <bpmndi:BPMNPlane
> bpmnElement="com.bp2s.oms.dealing.process.OrderReceptionProcess" >
>       <bpmndi:BPMNShape bpmnElement="_1" >
>         <dc:Bounds x="324" y="82" width="48" height="48" />
>       </bpmndi:BPMNShape>
>       <bpmndi:BPMNShape bpmnElement="_2" >
>         <dc:Bounds x="324" y="264" width="48" height="48" />
>       </bpmndi:BPMNShape>
>       <bpmndi:BPMNShape bpmnElement="_3" >
>         <dc:Bounds x="240" y="168" width="217" height="48" />
>       </bpmndi:BPMNShape>
>       <bpmndi:BPMNEdge bpmnElement="_3-_2" >
>         <di:waypoint x="348" y="192" />
>         <di:waypoint x="348" y="288" />
>       </bpmndi:BPMNEdge>
>       <bpmndi:BPMNEdge bpmnElement="_1-_3" >
>         <di:waypoint x="348" y="106" />
>         <di:waypoint x="348" y="192" />
>       </bpmndi:BPMNEdge>
>     </bpmndi:BPMNPlane>
>   </bpmndi:BPMNDiagram>
>
> </definitions>
>
> ----- END BPMN
>
>
> 3/ Memory dump after forcing GC
>
> OrderContext is always here after calling BPMN with orderContext in
> process parameter
>
>
>
> Thanks in advance,
>
> Regards,
>
>
> Paul
>
>
>
> [image: Inactive hide details for salaboy---03/06/2014 11:58:47---Can you
> please provide a reproducer for this: 2/ We try to change thi]salaboy---03/06/2014
> 11:58:47---Can you please provide a reproducer for this: 2/ We try to
> change this in moving object (prototype)
>
>
>
>  *Re: [jbpm-dev] process instance BPMN and variable scope memory leak*
>
>
>    *(Internet)*
>    *salaboy *
>
>
>    To:
>    Paul CHAU N'GUYEN
>    Cc:
>    jbpm-dev
>    03/06/2014 11:58
>
>
> ------------------------------
>
>
>
> Can you please provide a reproducer for this:
>
> 2/ We try to change this in moving object (prototype) to process
> parameters map, --> still the same issue: after bpmn execution object is
> still there JVM garbage collection can not removed it
>
> so we can check it out?
>
> Usually a Junit inside a maven project is enough
>
>
> On Tue, Jun 3, 2014 at 10:41 AM, <*paul.chaunguyen at externe.bnpparibas.com*
> <paul.chaunguyen at externe.bnpparibas.com>> wrote:
>
>    Dear all,
>
>    We are facing big issue with variable scope so application failed to
>    out of memory with BPMN.
>
>    Our situtation is below
>
>    1/ Initially, we put an object (prototype) as global inside BPMN -->
>    after bpmn execution object is still there JVM garbage collection can not
>    removed it
>
>    2/ We try to change this in moving object (prototype) to process
>    parameters map, --> still the same issue: after bpmn execution object is
>    still there JVM garbage collection can not removed it
>
>
>    3/ We try to use this object as facts but can not get the good syntax
>    in java dialect to process as document or user guide related BPMN is very
>    poor, Can you help please ?
>
>    Many thanks,
>
>
>    Regards,
>
>    Paul
>
>    This message and any attachments (the "message") is
>    intended solely for the intended addressees and is confidential.
>    If you receive this message in error,or are not the intended
>    recipient(s),
>    please delete it and any copies from your systems and immediately
>    notify
>    the sender. Any unauthorized view, use that does not comply with its
>    purpose,
>    dissemination or disclosure, either whole or partial, is prohibited.
>    Since the internet
>    cannot guarantee the integrity of this message which may not be
>    reliable, BNP PARIBAS
>    (and its subsidiaries) shall not be liable for the message if
>    modified, changed or falsified.
>    Do not print this message unless it is necessary,consider the
>    environment.
>
>
>    ----------------------------------------------------------------------------------------------------------------------------------
>
>    Ce message et toutes les pieces jointes (ci-apres le "message")
>    sont etablis a l'intention exclusive de ses destinataires et sont
>    confidentiels.
>    Si vous recevez ce message par erreur ou s'il ne vous est pas destine,
>    merci de le detruire ainsi que toute copie de votre systeme et d'en
>    avertir
>    immediatement l'expediteur. Toute lecture non autorisee, toute
>    utilisation de
>    ce message qui n'est pas conforme a sa destination, toute diffusion ou
>    toute
>    publication, totale ou partielle, est interdite. L'Internet ne
>    permettant pas d'assurer
>    l'integrite de ce message electronique susceptible d'alteration, BNP
>    Paribas
>    (et ses filiales) decline(nt) toute responsabilite au titre de ce
>    message dans l'hypothese
>    ou il aurait ete modifie, deforme ou falsifie.
>    N'imprimez ce message que si necessaire, pensez a l'environnement.
>
>
>    _______________________________________________
>    jbpm-dev mailing list
> *jbpm-dev at lists.jboss.org* <jbpm-dev at lists.jboss.org>
> *https://lists.jboss.org/mailman/listinfo/jbpm-dev*
>    <https://lists.jboss.org/mailman/listinfo/jbpm-dev>
>
>
>
>
>
> --
>  - MyJourney @ *http://salaboy.com* <http://salaboy.wordpress.com/>
>  - Co-Founder @ *http://www.jugargentina.org*
> <http://www.jugargentina.org/>
>  - Co-Founder @ *http://www.jbug.com.ar* <http://www.jbug.com.ar/>
>
>  - Salatino "Salaboy" Mauricio -
>
>


-- 
 - MyJourney @ http://salaboy.com <http://salaboy.wordpress.com>
 - Co-Founder @ http://www.jugargentina.org
 - Co-Founder @ http://www.jbug.com.ar

 - Salatino "Salaboy" Mauricio -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jbpm-dev/attachments/20140603/12c06d15/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/jbpm-dev/attachments/20140603/12c06d15/attachment-0004.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/jbpm-dev/attachments/20140603/12c06d15/attachment-0005.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic01515.gif
Type: image/gif
Size: 1255 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/jbpm-dev/attachments/20140603/12c06d15/attachment-0006.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2B573358.gif
Type: image/gif
Size: 31688 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/jbpm-dev/attachments/20140603/12c06d15/attachment-0007.gif 


More information about the jbpm-dev mailing list