Files
Jack Franklin d05cbc0511 fix(performance): prevent memory leak by scoping trace engine model per parse (#2720)
## Rationale

DevTools' `TraceEngine.TraceModel.Model` permanently retains parsed
traces in an internal recordings array (`#traces`). Calling
`engine.resetProcessor()` between runs only resets the underlying
processor and does not clear `#traces`.

Because `engine` was previously instantiated as a module-scoped
singleton, every performance trace recorded or parsed in a session
remained permanently held in heap memory for the lifetime of the
process.

## Changes

- In `src/processors/PerformanceTrace.ts`, instantiate
`DevTools.TraceEngine.TraceModel.Model.createWithAllHandlers()` per
invocation of `parseRawTraceBuffer()`.
- Remove the module-scoped `engine` singleton and the obsolete
`engine.resetProcessor()` call.
- Add a unit test in `tests/trace-processing/parse.test.ts` verifying
that consecutive trace parses construct isolated `Model` instances and
keep internal trace retention bounded at 1.
- Add a profiling regression scenario in
`scripts/profile/scenarios/performance_trace.ts` to guard against memory
retention across consecutive traces during `npm run test:memory`.
2026-09-10 15:37:28 +00:00
..
2025-09-11 12:46:05 +02:00