diff options
author | Jamis Buck <jamis@37signals.com> | 2005-10-14 15:04:57 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-10-14 15:04:57 +0000 |
commit | e2fc88eef49af4ca8e35ae78ce3221c947e168c7 (patch) | |
tree | d337f6a9433416781d0a42fe1b5b9fbc0b7a4f87 /activerecord/lib | |
parent | 86455d31f2ee88c9f476627ee6ebf1b242d962bb (diff) | |
download | rails-e2fc88eef49af4ca8e35ae78ce3221c947e168c7.tar.gz rails-e2fc88eef49af4ca8e35ae78ce3221c947e168c7.tar.bz2 rails-e2fc88eef49af4ca8e35ae78ce3221c947e168c7.zip |
Avoid memleak in dev mode with fastcgi
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2584 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 8af2c33ce5..be8b672fa7 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -940,9 +940,14 @@ module ActiveRecord #:nodoc: # end def define_attr_method(name, value=nil, &block) sing = class << self; self; end - block = proc { value.to_s } if value - sing.send( :alias_method, "original_#{name}", name ) - sing.send( :define_method, name, &block ) + sing.send :alias_method, "original_#{name}", name + if value + # use eval instead of a block to work around a memory leak in dev + # mode in fcgi + sing.class_eval "def #{name}; #{value.to_s.inspect}; end" + else + sing.send :define_method, name, &block + end end protected |