Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Memory leak in cURL transport #39

Closed
PawelDecowski opened this Issue · 5 comments

4 participants

@PawelDecowski

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.

@jkimbo

+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: https://github.com/rmccue/Requests/blob/master/library/Requests/Transport/cURL.php#L245 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?

@BUGHUNTER

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

@PawelDecowski

Any chance of a response?

@ozh

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

@PawelDecowski

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
617eff1
@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.