Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Memory leak in cURL transport #39

PawelDecowski opened this Issue · 5 comments

4 participants


I discovered a memory leak in the cURL transport. When doing multiple Requests::request() calls (for example in a loop) the memory usage keeps growing (in my case by 3–5MB every call).

I’ve narrowed it down to $this->fp not being closed in the cURL transport’s request() method. Now, this shouldn’t cause the memory leak, as a transport is instantiated in the scope of the Requests::request() method so it (and thus all its instance variables, including $this->fp) should be released when that method call completes.

I tried looking for a reference to the transport which is not released but can’t find any.

The temporary solution is to add curl_close($this->fp) just before the Requests_Transport_cURL::request() returns. Although it does fix the problem, it does not fix it at the source.

Before I fork your repo and add the temporary fix I thought I’d let you know so maybe you can find the real cause of this bug — since you’re more familiar with your code.


+1 to this. Came across this issue today when trying to use request to download multiple files and was coming across a php error that the system could not open any more files because the curl connections weren't being closed. It should be closed here: but only if "blocking" is set to false? What exactly is the purpose of the "blocking" option and why does the curl connection only get closed if it is set to false?


How is the status with this issue? Is there another solution than using curl_close directly? Thanks.


Any chance of a response?


where's the pull request that fixes it? :)


This is one solution: #59. But read my description of the issue for details.

@rmccue rmccue closed this issue from a commit
Josh Freeman Close cURL handle before returning
Fixes #39, #59
@rmccue rmccue closed this in 617eff1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.