Memory leak in cURL transport #39

Closed
PawelDecowski opened this Issue Feb 1, 2013 · 5 comments

Comments

Projects
None yet
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

This comment has been minimized.

Show comment Hide comment
@jkimbo

jkimbo Mar 4, 2013

+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?

jkimbo commented Mar 4, 2013

+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

This comment has been minimized.

Show comment Hide comment
@BUGHUNTER

BUGHUNTER Apr 14, 2013

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

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

@PawelDecowski

This comment has been minimized.

Show comment Hide comment
@PawelDecowski

PawelDecowski Jun 18, 2013

Any chance of a response?

Any chance of a response?

@ozh

This comment has been minimized.

Show comment Hide comment
@ozh

ozh Jun 18, 2013

Collaborator

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

Collaborator

ozh commented Jun 18, 2013

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

@PawelDecowski

This comment has been minimized.

Show comment Hide comment
@PawelDecowski

PawelDecowski Jun 18, 2013

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment