kr/beanstalk-client-ruby — Issue #11: Memory leak when used with bundler/setup and accessing job.stats["tube"]
Author: dkam
Created: 2012-03-02 12:48:33+00:00
State: open

Hey there,

I use beanstalk in rails and within an external daemon which processes jobs in a queue. I use

job.stats["tube"]

to determine which tube a job came from. Is this a valid operation?

When used with 'bundler/setup', memory usage slowly grows and isn't released.

Running the code below:

* without accessing job.stats["tube"] and excluding 'bundler/setup': 15.7 MB
* including accessing job.stats["tube"] and excluding 'bundler/setup': 18.8 MB
* without accessing job.stats["tube"] and including 'bundler/setup': 23.9 MB
* including accessing job.stats["tube"] and including 'bundler/setup': 567MB

```ruby
require "bundler/setup"
require 'beanstalk-client'

beanstalk = Beanstalk::Pool.new(["localhost:11300"])

beanstalk.use "ping"

# Load up beanstalkd

50000.times {|i| beanstalk.put("PING! - #{i}")}

# Grab out entries and delete them.

beanstalk.watch("ping")
job = nil

loop do
begin
job = beanstalk.reserve(1)
rescue Beanstalk::TimedOut
puts "So bored."
retry
end

# The following access to job.stats["tube"] causes the issue - but only when used with bundler.
puts job.stats["tube"]
puts "Deleting job : #{job.body}"
job.delete
end
```

Anyone else seen this?