Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't include locals in envvar when calling to_proc #592

Closed
wants to merge 1 commit into from

Conversation

csfrancis
Copy link

We've encountered a problem in Shopify production where unnecessary controller context is being retained by the sym_proc_cache. 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.

@nobu nobu closed this in 2f3b28c Apr 12, 2014
haileys pushed a commit to github/ruby that referenced this pull request Apr 14, 2014
* string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear
  caller's self which is useless, so that it can get collected.
  [Fixes rubyGH-592]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Conflicts:
	ChangeLog
haileys pushed a commit to github/ruby that referenced this pull request Apr 14, 2014
* string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear
  caller's self which is useless, so that it can get collected.
  [Fixes rubyGH-592]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Conflicts:
	ChangeLog
mmasaki pushed a commit to mmasaki/ruby that referenced this pull request Apr 21, 2014
* string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear
  caller's self which is useless, so that it can get collected.
  [Fixes rubyGH-592]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
hsbt pushed a commit that referenced this pull request Oct 29, 2015
	* string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear
	  caller's self which is useless, so that it can get collected.
	  [Fixes GH-592]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@52362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant