N8N memory comsumption

Hello,

Here is my workflow:

Here’s what’s available in the aggregation code:

index = $input.all()[0].json.run_index
data = []

for (let pas = 0; pas < index; pas++) {
  new_array = $('Get Incidents').all(0, pas)[0].json.body
  data = data.concat(new_array)
 }

return {
        "data": data,
}

The idea is that a sub-workflow allows me to consume a paged API by passing it parameters and retrieving all the objects that the API returns.
I’ve detected a very high memory consumption. For a few hundred (around 300) MB of data, a few GB (6/7) of memory are consumed by the pod.
Browsing similar topics, I’ve read that N8N stores everything in memory while waiting for the workflow to finish ==> Could creating a workflow for each iteration of the loop reduce consumption?
Am I following a bad practice when creating this workflow?
Is there a parameter that could be used to configure n8n or a node that could be used to configure n8n or a node that could be used to configure n8n?

Thank you in advance,

Best regards

1 Like