Hi - my production instance of Mastra has been crashing with out of memory errors all weekend, after upgrading to observational memory and 1.5.0 on Friday. I've been fighting with Opus to try to nail down a root cause. Here are some suspicions:
- MastraModelOutput never clears #bufferedChunks / #bufferedSteps — the internal arrays accumulate data and are never released after the stream completes.
- Two ObservationalMemory instances are created per stream() call without explicit disposal.
- AbortSignal listeners are never removed on normal (non-aborted) stream completion.
- updateWorkingMemoryMutexes Map is never pruned — entries accumulate for every unique thread ID.
Overall, it seems that it is retaining spans (which in my case can be fairly large) and quickly exhaust the heap. I can't yet point to anything more specific than that.