Jump to content

Memory Leak In Curl Looping


Recommended Posts

Probably no-one will be able to help you without seeing your code and knowing how you use it.

Some general advices that I can give you are:

- remember to close every cURL handle after not using it anymore to free up server resources;

- if you want to make multiple connections at once multi cURL may be good choice;

- I found that often inserting some small pause inside of the loop while waiting for the multi cURL finishes the job in the form of ie. usleep(200) makes a big difference in a CPU usage.

Link to comment
Share on other sites

Some general advices that I can give you are: - remember to close every cURL handle after not using it anymore to free up server resources;

 

He's trying to be efficient and using the same handle, my guess is he might actually be bottlenecking it by doing so, eg his next loop is being processed using the same handle as the previous before it, the previous instance, has had a chance to finish.

 

If he explains what he's trying to do perhaps there might be a better solution, but making the process sleep before restarting is probably best at the moment.

Link to comment
Share on other sites

If you have access to the remote form set the action to the PHP script responsible for processing it on here without cURL.

 

If not just tell your script to sleep before rerunning the loop, this will give the server a chance to complete the processing and hopefully prevent the script from recursively chomping more and more system resources.

 

Better yet drop the loop count to something more reasonable.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...