Express

Unnecessary closures in hot paths increase memory allocation

info
performanceUpdated Feb 8, 2026(via Exa)
Technologies:
How to detect:

Creating new function objects (closures) inside request handlers or loops allocates memory for captured variables on every invocation, increasing GC pressure.

Recommended action:

Define mapper and utility functions once outside the request handler. Pass them as named functions to map/filter instead of inline arrow functions or anonymous functions.