Does running the “forEach” temporarily creates objects that will need to be treated by the GC ? I have to optimize a project and there’s a forEach on a quite big array, and we do tons of stuff inside that forEach
It is good.
Irrespective of this question, I strongly suggest to adopt a method to selective catch major performance issue and measure various implementation options.
If you don’t known how begin then take a look to
Sidenote: benchmarking in Java is pretty hard, but
async-profiler is a reasonable starting point.