Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql_query() memory problem

Status
Not open for further replies.

keesvanbreukelen

Programmer
Oct 28, 2002
8
NZ
When I run multiple mysql_query() commands over quite large tables, the memory usage goes up dramatically. The mysql_free_result() command does not seem to have any impact. I test using
echo memory_get_usage() . '<br />';
$rs = mysql_query($sql1);
echo memory_get_usage() . '<br />';
mysql_free_result($rs);
echo memory_get_usage() . '<br />';
$rs = mysql_query($sql2);
echo memory_get_usage() . '<br />';
mysql_free_result($rs);
echo memory_get_usage() . '<br />';
etc.
when I run the script on my local server (WAMP) memory appears to be released immediately. When I run it on the remote server (also Apache) I get the problem.

Kees
 
I have found that the difference here was the result of the memory_get_usage() function. On the server where it reported a high usage I managed to clock up about 400Mb before the script timed out. The maximum memory on this server is 64Mb. I have tried using memory_get_usage(true) which makes it look very much like the other server. I guess that this is a better check but from the documentation I find it hard to gleen what the real difference is. I welcome any comment to this memory_get_usage() mystery, but the supposed memory problem was not real and as such has been resolved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top