Hi,
I have some fairly boiler-plate Ruby code (running on Linux) which sends a GET request to a server ...
req = Net::HTTP::Get.new(path)
req.content_type = 'text/plain; charset=utf-8'
req.body = ''
port = 443
res = Net::HTTP.new($host, port)
res.use_ssl = true
res.start do |http|
t = Benchmark.measure do
_return = http.request(req).body
end
$time= t.real
end
req = nil
res = nil
The problem I'm having is that when I call this code in a tight loop, I eventually fill the system up with sockets in the TIME_WAIT state (48687 at last count).
I guess there's nothing special about Ruby here, I'd run into the same problem with C, but is there any GC related problem here? Any tips or tricks for preventing this from happening?