Hi,
I have a php script that runs a mysql query, then loops the result, and in that loop also runs several queries:
$sqlstr = "SELECT * FROM user_pred WHERE uprType != 2 AND uprTurn=$turn ORDER BY uprUserTeamIdFK";
$utmres = mysql_query($sqlstr) or trigger_error($termerror = __FILE__." - ".__LINE__.": ".mysql_error());
while($utmrow = mysql_fetch_array($utmres, MYSQL_ASSOC)) {
// some stuff happens here
// echo memory_get_usage() . " - 1241<br/>\n";
$sqlstr = "UPDATE user_roundscores SET ursUpdDate=NOW(),ursScore=$score WHERE ursUserTeamIdFK=$userteamid";
if(!mysql_query($sqlstr)) {
$err_crit++;
$cLog->WriteLogFile("Failed to UPDATE user_roundscores record for user $userid - teamuserid: $userteamid\n");
echo "Failed to UPDATE user_roundscores record for user $userid - teamuserid: $userteamid<br>\n";
break;
}
unset($sqlstr);
// echo memory_get_usage() . " - 1253<br/>\n";
// some stuff happens here too
}
The update query never fails.
For some reason, between the two calls of memory_get_usage
, there is some memory added. Because the big loop runs about 500.000 or more times, in the end it really adds up to alot of memory. Is there anything I'm missing here?
could it herhaps be that the memory is not actually added between the two calls, but at another point in the script?
Edit: some extra info: Before the loop it's at about 5mb, after the loop about 440mb, and every update query adds about 250 bytes. (the rest of the memory gets added at other places in the loop). The reason I didn't post more of the "other stuff" is because its about 300 lines of code. I posted this part because it looks to be where the most memory is added.