Skip to content

Instantly share code, notes, and snippets.

@driki
Last active December 10, 2015 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save driki/4400443 to your computer and use it in GitHub Desktop.
Save driki/4400443 to your computer and use it in GitHub Desktop.
Memory leak in Net::HTTP.get and non memory leak in HTTPClient.get which I think impacts Anemone https://github.com/NearbyFYI/anemone/blob/next/lib/anemone/http.rb#L136
require 'net/http'
# Memory continues to climb.
idx = 0
loop do
begin
# Our sample website
url = "http://localhost:2000"
resp = Net::HTTP.get(URI.parse(url))
puts "run loop: #{idx}"
idx += 1
rescue
# do nothing
end
sleep rand(0.1) # just a wait
end
require 'nokogiri'
require 'httpclient'
# Memory use is maintained
@@http_client = HTTPClient.new
@@http_client.connect_timeout = 60
idx = 0
loop do
begin
# Our sample website
url = "http://localhost:2000"
resp = @@http_client.get(url, :follow_redirect => true)
puts "run loop: #{idx}"
idx += 1
rescue
# do nothing
end
sleep rand(0.1) # just a wait
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment