Variables Should Not Be Declared inside the Loops
The following code can result in an error message "Too many new instances created" in the server log:
Groovy
for (...) {
def var = [:]
}
So you should always change it to this form:
Groovy
def var
for (...) {
var = [:]
}
The technical background is that the first script allocates a new variable which can increase the number of FormulaSandbox instances (above the limit).