codeigniter-mcurl icon indicating copy to clipboard operation
codeigniter-mcurl copied to clipboard

curl_close($this->calls[$key]['curl'])

Open glebovdev opened this issue 10 years ago • 3 comments

Multi-curl eats memory in a loop, so may be add curl_close($this->calls[$key]['curl']) inside execute() method for every particular curl handler?

May be curl_multi_remove_handle() and curl_multi_close() are not enough to clean used memory?

glebovdev avatar May 19 '14 18:05 glebovdev

Are you sure it's the curl objects causing the memory problems? Or could it be that you are loading too much data at once?

I'm not able to get to this right now, but after line 148 here in this file: https://github.com/chadhutchins/codeigniter-mcurl/blob/master/application/libraries/mcurl.php#L148

Try adding the following: curl_close($this->calls[$key]["curl"]);

Does that solve the issue?

chadhutchins avatar May 20 '14 04:05 chadhutchins

Actually that solves the problem. This manual says that individual curl_close() better to write after curl_multi_close() http://se2.php.net/manual/en/function.curl-multi-remove-handle.php

So after curl_multi_close($this->curl_parent); I've wrote again: foreach ($this->calls as $key => $call) curl_close($this->calls[$key]['curl']);

And now memory leaks problem almost solved. At least memory grows not so fast. And may be place curl_close() after 148 line could work too, I just didn't test it.

glebovdev avatar May 20 '14 09:05 glebovdev

Would you mind testing it out some and supplying the pull request so you can be attributed the fix?

chadhutchins avatar May 20 '14 11:05 chadhutchins