Skip to content

Commit f4fbd01

Browse files
committed
memo: release replacer closure during Memo.Detach
In #120875 we added a replacer closure to the memo, so that we could call back into `norm.Factory.Replace` from within `statisticsBuilder.factorOutVirtualCols`, which only has access to the memo and not the factory. This closure, however, means that the memo could potentially prevent GC of, or have an invalid reference to the factory after detachment. We shouldn't need to run the statistics builder on this memo after detaching from the factory (we shouldn't be constructing any new expressions in it) so let's go ahead and release the reference. Epic: None Release note: None
1 parent c285f81 commit f4fbd01

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pkg/sql/opt/memo/memo.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,8 @@ func (m *Memo) NextRoutineResultBufferID() RoutineResultBufferID {
628628
// constructed in this memo.
629629
func (m *Memo) Detach() {
630630
m.interner = interner{}
631+
m.replacer = nil
632+
631633
// It is important to not hold on to the EvalCtx in the logicalPropsBuilder
632634
// (#57059).
633635
m.logPropsBuilder = logicalPropsBuilder{}

0 commit comments

Comments
 (0)