note 29216 added to function.mysql-free-result
| From: | steve at stevedix dot de | Date: | Thu, 06 Feb 2003 09:58:27 +0000 |
| Subject: | note 29216 added to function.mysql-free-result | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-43503@lists.php.net to get a copy of this message | ||
Godyvdb below is making an incorrect assumption, which may confuse.
When you call a query, you are returned a handle, which points to a set of results and the
associated variables for it. When you call free_result with that handle it will do a garbage -
collection upon the result and associated variables, freeing up the memory.
What it WON'T do, and this is what Godyvdb is assuming, is optimise memory space by freeing all
memory taken up by similar queries. In his example
$myhandle=mysql_query("....");
mysql_free_result(mysql_query("...."));
all he does is makes another query to the database, generates a new handle, then immediately frees
up the space allocated to the result.
If you wish to free up memory, then you can only do so by quoting the correct handle. You cannot
generate a new handle to an existing query by the use of mysql_query.
eg.
$myhandle = mysql_query("....");
$anotherhandle =mysql_query("....");
mysql_free_result($myhandle);
$anotherhandle will still point to an existing set of results, whilst $myhandle won't. The two
handles are not related.
--
http://www.php.net/manual/en/function.mysql-free-result.php
http://master.php.net/manage/user-notes.php?action=edit+29216
http://master.php.net/manage/user-notes.php?action=delete+29216
http://master.php.net/manage/user-notes.php?action=reject+29216