ruby/ruby — pull request #592 by csfrancis (2014-04-11 12:50:38+00:00)
Title: Don't include locals in envvar when calling to_proc

We've encountered a problem in Shopify production where unnecessary controller context is being retained by the [`sym_proc_cache`](https://github.com/ruby/ruby/blob/f2606d6250d5f4b2e7d02b97567b74de6435864a/string.c#L8485-L8513). The problem is the creation of the proc from the symbol is in the context of a controller - as a result, when the proc is cached in `sym_proc_cache`, the controller and all of its context is being cached along with it. This causes memory to be unnecessarily retained beyond the lifetime of a request.

Our proposed solution is to not include local variables in the proc's environment context. As far as I can tell, it should not be possible to access local variables from a Proc when using `to_proc`.