demonstrate leak in LIFX gem
#!/usr/bin/ruby | |
gem 'lifx' | |
require 'lifx' | |
start_time = Time.now.to_i | |
prev_objs = ObjectSpace.count_objects | |
lifx = LIFX::Client.lan | |
lifx.discover! | |
light = lifx.lights.first | |
loop do | |
temp_c = light.temperature | |
temp_f = temp_c * (9.0 / 5.0) + 32 | |
GC.start # so we only count live objects | |
objs = ObjectSpace.count_objects | |
print "\nElapsed time: ", Time.now.to_i - start_time, " seconds\n" | |
print "Temperature: #{temp_c} C #{temp_f} F\n\n" | |
objs.each do |type, count| | |
delta = (count || 0) - (prev_objs[type] || 0) | |
printf "%10s => %8d delta %8d\n", type, count, delta | |
end | |
prev_objs = objs | |
sleep(600) | |
print "\n============================================================\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment