qiniu / ruby-sdk

Qiniu Resource (Cloud) Storage SDK for Ruby
MIT License
164 stars 138 forks source link

Update rest-client dependency to 2.0.0, and update json dependency #167

Closed bianjp closed 8 years ago

bianjp commented 8 years ago

rest-client 1.8.0 seems to have a memory leak. I'm not sure how to exactly determine whether it has a memory leak, but according to the following simple test, 2.0.0 uses much less memory and time than 1.8.0.

#!/usr/bin/env ruby
# ruby 2.3.1

gem 'rest-client', '~> 1.8.0'
#gem 'rest-client', '~> 2.0.0'
require 'rest-client'

puts RestClient::VERSION

start_time = Time.now

10000.times do
 # just an empty file behind nginx
  RestClient.get '127.0.0.1/test.html'
end

end_time = Time.now

GC.start
sleep 10

puts 'Memory: ' + `ps -p #{Process.pid} -o %mem | tail -1`.strip + '%'
puts "Time: #{end_time - start_time}s"

I find this when trying to address the memory leaks in my rails application. One api that use rest-client causes the memory usage grows continuously. If using rest-client 2.0.0, the memory usage will stop growing after reaching a fixed value.

rest-client 2.0.0 is largely API compatible with 1.8.0, and qiniu should work correctly with it. See rest-client history for more.

bianjp commented 8 years ago

@longbai Any responsible for this?

xuanyu-h commented 8 years ago

+1

longbai commented 8 years ago

LGTM,Thanks

bianjp commented 8 years ago

@longbai Can you release a new version?

longbai commented 8 years ago

好的

longbai commented 8 years ago

@bianjp done

xuanyu-h commented 8 years ago

👍

bianjp commented 8 years ago

@longbai You reverted json dependency from >= 1.8.0 to ~> 1.8.0 in this commit. Can you change it back to >= 1.8.0 or ~> 2.0.0?

json 2.0 droped support for Ruby < 2.0, but since qiniu has already droped support for Ruby <= 2.0 from 6.7, this should not be a problem. See its changelog for more.

By the way, updating mime-types dependency to 3.x would be great.

longbai commented 8 years ago

@bianjp 我来看下