When you unset() a mysql result, does it free the memory like mysql_free_result() does?
When you unset() a mysql result, does it free the memory like mysql_free_result() does?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No.
unset()clears the pointer to the result on php’s side, but does not do anything to the result it points to. The result of amysql_query()is simply a numerical identifier so that MySQL knows which result you’re referring for functions likemysql_fetch_array()and its companions. You need to usemysql_free_result()to tell MySQL that you’re done with that result; you can also unset the php variable afterwards as well, but as it’s just a resource, the time it takes to unset may not be worth the few bytes you save from unsetting it.