Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear thread data in the "checkin" method to fix memory leak #105

Merged
merged 1 commit into from
Jul 25, 2019

Conversation

ykitamura-mdsol
Copy link
Contributor

Still leaking memory when using with Faraday. Since the shutdown method added in #98 cannot be called from the Faraday adapter, empty arrays remain in the main thread after making requests:

Thread.current.keys
#=> [.., :"current-70179311374800", ..]
Thread.current[:"current-70179311374800"]
#=> {["example.org", 443]=>[]}

In the connection_pool gem, thread data is set to nil in the checkin method:

  def checkin
    if ::Thread.current[@key]
      if ::Thread.current[@key_count] == 1
        @available.push(::Thread.current[@key])
        ::Thread.current[@key]= nil
      else
        ::Thread.current[@key_count]-= 1
      end
    else
      raise ConnectionPool::Error, 'no connections are checked out'
    end

    nil
  end

This PR is following the logic to clear thread data in the checkin method.

@tenderlove It seems the change bumping the version to 3.0.1 is not merged into the master branch. How should I bump the version?

@jcarres-mdsol @jfeltesse-mdsol @cabbott @ssteeg-mdsol @piao-mdsol

@drbrain drbrain merged commit 585e090 into drbrain:master Jul 25, 2019
@ykitamura-mdsol ykitamura-mdsol deleted the fix/memory_leak branch November 18, 2019 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants