【发布时间】:2011-05-26 23:17:50
【问题描述】:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 24 bytes) in /home/fevsdiet/public_html/xxxxxxx.co.uk/booking/includes/functions.php on line 481
这是什么意思,如何解决?
这是出错的代码:
$availabilityArr = array();
#TODO - check if "to" is < "from" = means that "to" is +1 day.
$st = date("Y-m-d H:i", strtotime($date." +".$tt[2]." minutes"));
$et = date("Y-m-d H:i", strtotime($date." +".$tt[3]." minutes"));
$a = $st;
$n = 0; //layout counter
$b = date("Y-m-d H:i", strtotime($a." +".$int." minutes")); //default value for B is start time.
for( $a = $st ; $b <= $et ; $b =
date("Y-m-d H:i", strtotime($a." +".$int." minutes")))
{
$availabilityArr[date("Y-m-d", strtotime($a))][] = date("H:i", strtotime($a));
$a = $b;
$n++;
}
【问题讨论】:
-
可能有助于了解该线路附近/线路上发生的情况......也许有些事情比它应该花费的时间更长
-
不看代码我们是无法判断的。错误提示 内存耗尽。数组/对象太多或太大,可能是在(永无休止的)循环中引起的。使用带有调试器的 IDE。
-
当我的“每页”限制设置为 5000 而不是 50 时,我收到了这条消息。检查你所有的 for 循环...等,以确保它们不会卡在无休止地回显事物循环,或者你不想在 SQL 中加入太多东西,然后回显它们。
-
您的代码(而且您的
for循环看起来很丑:/。考虑使用while和明确的变量名称。 -
不一定是 481 导致内存填满。那可能只是当它没有剩余内存时碰巧尝试分配的那行?