Hi everyone, I have this piece of code: $namelist = mysql_query("SELECT username FROM users") or die('Error:' . mysql_error() . '<br />Error number:' . mysql_errno()); $namearray = mysql_fetch_array($namelist); PHP: I want to use mysql_free_result to save memory. Would I call it on $namelist, $namearray, or both? Also, could I just use unset() on those variables? Thanks, -Tony
You would call it on the resource returned by mysql_query(), in your case $namelist. Note that Mysql PHP extension usage is discouraged.
Okay. Could I call unset() on $namearray, to free more memory? Also, I know about the mysql php extension being discouraged. I'm still learning PDO. Thanks, -Tony
unset() removes the variable but it does not free the underlying resource. $namearray is an array, so yes. Didn't mean to be condescending with the Mysql remark, many people use it because they find online examples and don't bother to read the manual
Why don't you use memory_get_usage() to check mysql_free_result() and unset() effect on your script memory usage?
Good idea. But now, I just started my website. I have one user (me!). I'm just thinking for the future... -Tony
You're using a lot of resources to clear the memory. Shooting yourself in the foot. Offset it a bit by using mysqli