1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/examples/leak.rb
2018-02-06 12:27:14 -08:00

27 lines
498 B
Ruby

# Making sure we do not leak memory
require 'sidekiq'
$c = 0
$max = 10_000
# Start up sidekiq via
# ./bin/sidekiq -r ./examples/leak.rb > /dev/null
class MyWorker
include Sidekiq::Worker
def perform
$c += 1
if $c % 100 == 0
GC.start
memory = `ps -o rss -p #{Process.pid}`.chomp.split("\n").last.to_i
$stderr.puts "Using memory #{memory}"
end
if $c >= $max
exit
end
end
end
# schedule some jobs to work on
$max.times { MyWorker.perform_async }