cancel
Showing results for 
Search instead for 
Did you mean: 

Script Task within a loop causing StackOverflowError

zlatan316
Champ on-the-rise
Champ on-the-rise

We have a simple script task in a BPMN that is within a loop that is designed to loop around 500 times. The script task simply creates a string variable. We can see when we don't mark the script as asynchronous, we see a StackOverflowError after around 30 loops occur. If we mark it as asynchronous, we do not see the error.

Is there any indication why this occurs specifically with script tasks and not with any other tasks such as service tasks?

5 REPLIES 5

daisuke-yoshimo
Star Collaborator
Star Collaborator

After writing the recursive logic, the stack will be expanded, so StackOverflowError will occur.

How about increasing the thread stack size with JVM parameters?

-Xss:10m

-X Command-line Options

This is also something but we would need to be able to scale the stack if request and load increases on activiti, which is why I was wondering if there was something specific that only seems to cause it with script tasks in a loop, or indeed if there is an activiti element that can stop it occuring?

Since the Xss option is related to the maximum value, I think the thread size will be expanded as necessary.

If we need to examin why the stack will be expanded, we need to check your script.

Makes sense. The script was simply creating an integer variable and adding 1 to it, but it is possible it can run thousands of times due it it being in a loop.

daisuke-yoshimo
Star Collaborator
Star Collaborator

Well, please upload the reproduction code (>_<) if you wanto to resolve this problem.