I have alot of variables in my script, should i use unset() to reset them after their use is finished ? if i have 20 unset() calls, doesnt this introduce unnecessary function call overhead ? Is the overhead lesser than the memory required to store those vars ? Which is better ? using unset() or keeping the vars as is ?
That depends on how much data these variables contain. Can you be more specific about that? And you don't need to call unset() for each variable, you can do: unset($foo, $bar, $lala, $some, $thing); PHP:
I wouldn't bother unsetting them, in this case. The int variables will hold just a few bytes, and the MySQL results, well depends on what you've fetched previously. If it's a lot of data (binary images, etc...), then I'd probably unset them. But personally, I've only used unset() in a very few occasions.
At the last line, yes... PHP will automatically destroy them at the end of the execution of the script anyway. If you want to call it at all, do it right after the variable becomes useless to you. Also regarding this: unset() is a language construct, and not a function, and therefore much faster than a function.