String concatenation in loops causes quadratic memory allocation
warningperformanceUpdated Feb 8, 2026(via Exa)
Technologies:
How to detect:
Building large strings using += operator in loops creates a new string object on every iteration, resulting in O(n²) time complexity and excessive allocations.
Recommended action:
Use array of strings with join() instead. Pre-allocate array size when known. This reduces 100,000 row processing from ~340ms to ~15ms.