Prototype instance cleanup behavior in long-running CLI processes
0 reputation · 14 Oct 2025, 09:51 UTC
Context
The Extbase ObjectManager was patched in TYPO3 10.4.14 and 11.5.2 to stop retaining prototype-scoped objects in the singleton cache, allowing them to be garbage-collected. The change prevents unbounded memory growth when prototype dependencies are created repeatedly during a single long-running CLI command or daemon.
Open behavior
After the fix, prototype instances are no longer cached, but the framework does not automatically clear any references that may still be held by the ObjectManager or its container at the end of a logical request cycle inside a persistent process. Developers must decide whether to call ObjectManager::reset() (or an equivalent container reset) between cycles, or rely on PHP's garbage collector to reclaim memory once references fall out of scope.
Questions
- Is there a documented or recommended pattern for resetting prototype state between logical requests in a long-running CLI command?
- Does the current ObjectManager contract guarantee that no internal references to prototype instances remain after the creating code releases its own references?
- Are there plans to introduce an automatic per-cycle cleanup hook for CLI contexts in a future TYPO3 release?