Eugene Eugene - 3 years ago 263
PHP Question

difference between executing curl_close() once or frequently?

When is it necessary to close curl connection and release resources consumed by it?

Why do I ask this question, well quite simply because I was told, that PHP garbage collector does all of this and sometimes there is no need to close DB connection or call the

method to release resources.

Since, that moment I actually started to think about where do I need to call it then? At the moment I'm interested with that question since I writing a small library for curl and I'd like to understand when do I need to user

Thank you all for discussion and explanation of it.

Answer Source

as far as i understand it. The GC only cleans up resources that are no longer used/referenced. as whenever the curl variable fall out of scope, it'll be cleaned up. But that might only happen after the script has finished, or whenever the session is destroyed (depending on scope).

But to be on the safe side, just follow common sense.. close it when its no longer needed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download