Describe the problem
When a query plan which is not fully optimized is cached, it retains a pointer to the *tree.EvalContext via the logicalPropBuilder. This retained reference can manifest as a relatively severe memory leak when those cached values end up retaining different SystemConfigs which can end up being rather large.
Environment:
This issue affects at least v20.1.x and v20.2.x. Ideally a fix would be available for backport.