title: Mechanize - Receiving Errno::EMFILE: Too many open files - socket(2) after a day
body: <p>I'm running an application that uses mechanize to fetch some data every so often from an RSS feed.</p>
  
  <p>It runs as a heroku worker and after a day or so I'm receiving the following error:
  Errno::EMFILE: Too many open files - socket(2)</p>
  
  <p>I wasn't able to find a "close" method within mechanize, is there anything special I need to be doing in order to close out my browser sessions?</p>
  
  <p>Here is how I create the browser + read information:</p>
  
  <pre><code>  def mechanize_browser
      @mechanize_browser ||= begin
        agent = Mechanize.new
        agent.redirect_ok = true
        agent.request_headers = {
          'Accept-Encoding' =&gt; "gzip,deflate,sdch",
          'Accept-Language' =&gt; "en-US,en;q=0.8",
        }
        agent
      end
    end
  </code></pre>
  
  <p>And actually fetching information:</p>
  
  <pre><code>  response = mechanize_browser.get(url)
  </code></pre>
  
  <p>And then closing after the response:</p>
  
  <pre><code>  def close_mechanize_browser
      @mechanize_browser = nil
    end
  </code></pre>
  
  <p>Thanks in advance!</p>