Foreach need to clear it?

it’s a performance question, each time that i make foreach (blueprint) must be closed/cleared/delete?
every time i do foreach, this, remains in memory ?
When i call 1000 foreach (the same repeated) i have 1000 list in memory or they auto-refresh?

in my situation i call foreach for get enemy around me but once he called him can be destroyed.

I think Garbage Collector deals with that on its own. You can add a Collect Garage node after the ForEach finishes to be one the safe side, but I frankly don’t think that array remains in the memory for too long.

If you look at the implementation of the ForEachLoop node, you’ll see that the array is not stored inside the node ever. It just always re-evaluates your input, so it won’t store any references to your array.

many thanks