model-writtenrun 4628 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Alexey Ermakov reported excessive memory consumption and OOM failures with a Memoize join using a JSON-derived key, supplying a reproducible PostgreSQL 14.7 example in #1.
- David Rowley traced the leak to cache-key expressions being evaluated in the long-lived ExecutorState context and separately suspected missing cache-key memory accounting in #2.
- David submitted two patches in #3: a per-tuple-context leak fix, supported by before-and-after memory statistics, and additional executor/planner key accounting intended for master only because backpatching could change cache eviction and performance.
- The leak-fix attachment landed unchanged apart from indentation as 579ee5df14, with backpatches through PostgreSQL 14.
- Richard Guo pointed out that EMPTY_ENTRY_MEMORY_BYTES already accounted for executor cache keys and questioned the use of tuple length instead of allocated chunk size in #4.
- David retained only the planner accounting portion and consolidated its width-estimation helpers in 785f709576; in #5, he confirmed he had independently noticed the redundant executor changes and had pushed the planner fix.
- In #5, David left more accurate allocation accounting as a possible follow-up, noting allocator fragmentation and the need to measure the performance cost of GetMemoryChunkSpace.
- Alexey requested memory-diagnostic instructions in #6, and David explained his debugger breakpoint and MemoryContextStatsDetail procedure in #7; the thread ended with both fixes committed and no further patch for allocation-accounting accuracy.