Last active
December 15, 2015 07:59
-
-
Save yosiat/5227250 to your computer and use it in GitHub Desktop.
Memory leak in sidekiq http://stackoverflow.com/questions/15533869/sidekiq-worker-is-leaking-memory
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
class ImportWorker | |
include Sidekiq::Worker | |
include Sidekiq::Status::Worker | |
def get_command | |
# This command just returns the "git-tf clone .." command, getting from config file the paramters | |
# and concating all | |
command | |
end | |
def perform | |
IO.popen(get_command) do |stdin,stdout| | |
chars = [] | |
last_percent = 0 | |
while(char = stdin.getc) | |
if char == '%' | |
last_numbers = chars[-3..-1].reject { |c| c.match(/\d/).nil? } | |
current_percent = last_numbers.join.to_i | |
if current_percent < last_percent | |
current_percent = last_percent + current_percent | |
end | |
at current_percent, 100 | |
last_percent = current_percent | |
chars = [] | |
end | |
chars << char | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I believe i'm also experiencing a memory leak in SideKiq. Did you find a solution to this problem? Have you heard anything else or identified the source? I appreciate the help.