Last active
November 19, 2015 09:01
-
-
Save ebeigarts/44648eb7b2773e102335 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
#!/usr/bin/env ruby | |
class Infinity | |
def self.run | |
1.times { run } | |
end | |
end | |
Thread.new do | |
loop do | |
begin | |
puts "T1: Start infinity" | |
Infinity.run | |
rescue Exception => e | |
puts "T1: #{e.message}" | |
end | |
puts "T1: Sleep infinity" | |
sleep 3 | |
end | |
end | |
7.times do | |
GC.start | |
puts "GC major: #{GC.stat[:major_gc_count]}, minor: #{GC.stat[:minor_gc_count]}, threads: #{Thread.list.size}" | |
sleep 1 | |
end | |
puts "Done." | |
# $ ruby -v | |
# ruby 2.3.0dev (2015-11-19 trunk 52668) [x86_64-darwin15] | |
# | |
# T1: Start infinity | |
# GC major: 1, minor: 0, threads: 2 | |
# T1: stack level too deep | |
# T1: Sleep infinity | |
# GC major: 2, minor: 0, threads: 2 | |
# GC major: 3, minor: 0, threads: 2 | |
# T1: Start infinity | |
# | |
# $ ps aux | grep -E '[R]SS|[r]uby' | |
# USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND | |
# ebeigarts 27301 58.2 0.6 2511120 48596 s006 R+ 10:46AM 1:04.51 ruby ./gc_threads_issue.rb | |
# | |
# $ kill 27301 | |
# $ sleep 60 | |
# | |
# $ ps aux | grep -E '[R]SS|[r]uby' | |
# USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND | |
# ebeigarts 27301 55.9 0.6 2511120 48596 s006 S+ 10:46AM 2:10.72 ruby ./gc_threads_issue.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment