note 29216 deleted from function.mysql-free-result by philip
| From: | philip@php.net | Date: | Wed, 21 Feb 2007 07:16:25 +0000 |
| Subject: | note 29216 deleted from function.mysql-free-result by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123622@lists.php.net to get a copy of this message | ||
Note Submitter: steve at stevedix dot de
----
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.