cancel
Showing results for 
Search instead for 
Did you mean: 

Out of memory issues when doing lots of variable get/set

krdevos
Champ in-the-making
Champ in-the-making
Hi,

I'm using activiti in a prodcution environment to handle a simple sort of approval flow. I put a serializable object to the processinstance to pass through the different steps. There is also a possibility to update the variable without changing task.

However when I try to do a lot of get variables and set again I get an out of memory exception, probably a stream that's not closed each time.

We merely use taskservice and runtimeservice.getVariables, but calling this a few time in a row, with a serializable object of a few MB will result in an out of memory issue.

Anyone has an idea to solve this?

thx

at org.activiti.engine.impl.variable.SerializableType.getValue(SerializableType.java:49)
   at org.activiti.engine.impl.persistence.entity.VariableInstanceEntity.getValue(VariableInstanceEntity.java:158)
   at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.collectVariables(VariableScopeImpl.java:84)
   at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.collectVariables(VariableScopeImpl.java:81)
   at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.getVariables(VariableScopeImpl.java:65)
   at org.activiti.engine.impl.cmd.GetTaskVariablesCmd.execute(GetTaskVariablesCmd.java:62)
   at org.activiti.engine.impl.cmd.GetTaskVariablesCmd.execute(GetTaskVariablesCmd.java:31)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.TaskServiceImpl.getVariables(TaskServiceImpl.java:172)
3 REPLIES 3

trademak
Star Contributor
Star Contributor
Hi,

A serialized object of a couple of MBs is not really a normal way of using process variables.
Is it not possible to store a reference to the serialized object in the process instance and store the object itself somewhere else?

Best regards,

krdevos
Champ in-the-making
Champ in-the-making
Tijs,

THX for the reply. And I must admit your response is a valid one, however changing this current architecture would take some serious refactoring time and money.

Do you mean that the architecture of activiti is not setup to handle a large serialized block of data as process variable?

thx

Kristof

trademak
Star Contributor
Star Contributor
Hi,

Well, it's certainly not the best practice on how to use process variables.
Do you do these getVariable calls within the same transaction? So does it only contain synchronous service tasks etc?
Then all the variables may still be in memory.
How much MB are we talking about in total? Can't you increase the memory settings?
If you do the getVariable calls in the same transaction then switching to asynchronous tasks could be a solution.

Best regards,