Created
July 4, 2012 16:31
-
-
Save vangberg/3048173 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby -v | |
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] | |
$ rails -v | |
Rails 3.2.6 | |
$ mkdir memory_leak | |
$ cd memory_leak | |
$ rails new . | |
$ rails g model Stub | |
$ bundle exec rake db:create db:migrate | |
$ rails runner ml.rb | |
In loop: 0 | |
Not in loop: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "./ml.rb" | |
1.times {stub_all} | |
GC.start | |
puts base_count #=> 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "./ml.rb" | |
stub_all | |
GC.start | |
puts base_count #=> 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "./ml.rb" | |
begin stub_all end | |
GC.start | |
puts base_count #=> 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stub_all | |
Stub.all.each {} | |
nil | |
end | |
def base_count | |
ObjectSpace.each_object(ActiveRecord::Base).count | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment