-
-
Save BanzaiMan/751136 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
require 'singleton' | |
loop do | |
classes = [] | |
1000.times do | |
classes << Class.new do | |
include Singleton | |
end | |
end | |
(0..10).map do | |
Thread.new do | |
classes.each do |cls| | |
cls.instance | |
end | |
end | |
end.map(&:join) | |
puts "loop completed" | |
end | |
% ruby -v singleton_killer.rb | |
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10.4.0] | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
singleton_killer.rb:18: undefined method `instance' for #<Class:0x1001896a0> (NoMethodError) | |
from singleton_killer.rb:1:in `join' | |
from singleton_killer.rb:1:in `to_proc' | |
from singleton_killer.rb:21:in `map' | |
from singleton_killer.rb:21 | |
from singleton_killer.rb:5:in `loop' | |
from singleton_killer.rb:5 | |
% ruby -v singleton_killer.rb | |
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
singleton_killer.rb:18: undefined method `instance' for #<Class:0x100348c70> (NoMethodError) | |
from singleton_killer.rb:1:in `join' | |
from singleton_killer.rb:1:in `to_proc' | |
from singleton_killer.rb:21:in `map' | |
from singleton_killer.rb:21 | |
from singleton_killer.rb:5:in `loop' | |
from singleton_killer.rb:5 |
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
asari@ubuntu:~$ ruby -v singleton_killer.rb | |
ruby 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux] | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
singleton_killer.rb:14: undefined method `instance' for #<Class:0x7fec77bd45c8> (NoMethodError) | |
from singleton_killer.rb:1:in `join' | |
from singleton_killer.rb:1:in `to_proc' | |
from singleton_killer.rb:17:in `map' | |
from singleton_killer.rb:17 | |
from singleton_killer.rb:3:in `loop' | |
from singleton_killer.rb:3 |
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
[❼-1.8.7-p302]:~ $ ruby 751125.rb | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
loop completed | |
751125.rb:14: undefined method `instance' for #<Class:0x100523630> (NoMethodError) | |
from 751125.rb:1:in `join' | |
from 751125.rb:1:in `to_proc' | |
from 751125.rb:17:in `map' | |
from 751125.rb:17 | |
from 751125.rb:3:in `loop' | |
from 751125.rb:3 | |
[❼-1.8.7-p302]:~ $ ruby -v 751125.rb | |
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10.5.0] | |
loop completed | |
751125.rb:14: undefined method `instance' for #<Class:0x100635730> (NoMethodError) | |
from 751125.rb:1:in `join' | |
from 751125.rb:1:in `to_proc' | |
from 751125.rb:17:in `map' | |
from 751125.rb:17 | |
from 751125.rb:3:in `loop' | |
from 751125.rb:3 | |
[❼-1.8.7-p302]:~ $ ruby -v 751125.rb | |
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10.5.0] | |
loop completed | |
loop completed | |
loop completed | |
751125.rb:14: undefined method `instance' for #<Class:0x1006119c0> (NoMethodError) | |
from 751125.rb:1:in `join' | |
from 751125.rb:1:in `to_proc' | |
from 751125.rb:17:in `map' | |
from 751125.rb:17 | |
from 751125.rb:3:in `loop' | |
from 751125.rb:3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment