echo number_format(memory_get_usage()/1048576, 2).'<br/>';
$sql = "query";
$result = mysql_query($sql);
while($property = mysql_fetch_object($result)){
continue;
}
echo number_format(memory_get_usage()/1048576, 2);
上面只使用了15mb的内存(两个回声之间从7到22mb)。它是一个很大的数据集。
我试过了:
$property = null;
继续之前。我也试过
mysql_free_result ($result);
没有成功。
答案 0 :(得分:0)
这可能与PHP无关。相反,你的mysql数据库正在缓存结果以保存自己潜在的未来读取,因为它设置为:http://dev.mysql.com/doc/refman/5.1/en/query-cache.html
在该链接上列出了几个用于禁用查询缓存的选项。
答案 1 :(得分:0)
答案是使用mysql_unbuffered_query函数,该函数不包含内存中的结果集,与mysql_query不同。
感谢airthomas建议我寻找与mysql_use_result相当的