tags:

views:

115

answers:

1

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 __destuct 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 curl_close() function.

Thank you all for discussion and explanation of it.

A: 

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.

Ollie
But, woun't it be unnecessary code then?
Eugene