doupingdiao3546 2017-06-05 18:41
浏览 639
已采纳

PHP致命错误:允许的内存大小为268435456字节

I am getting the following error when clicking on a category named Test

FastCGI sent in stderr:

PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 32 bytes) in /home/mydomain/public_html/app/functions/fn.catalog.php on line 736" while reading response header from upstream, client: 24.xx.xx.xx, server: www.mydomain.com, request: "GET /test-page-313/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.mydomain.com", referrer: "http://www.mydomain....lesale-towels/"

My 736 Line is as follows

In my php.ini I've already increase the memory_limit to = 1G

for ($qty = $min_qty; $qty <= $max_qty; $qty += $product['qty_step']) {
    $qty_content[] = $qty;
}
  • 写回答

1条回答 默认 最新

  • dqy1265 2017-06-05 18:57
    关注

    Several possibilities :

    • $product['qty_step'] doesn't contain a number
    • There are two many steps in your loop that makes your program creating many entries in the $qty_content array.

    For example, if you have:

    $min_qty = 0;
    $max_qty = 400000;
    $product = array("qty_step" => 0.001);
    $qty_content = [];
    
    // The loop
    for ($qty = $min_qty; $qty <= $max_qty; $qty += $product['qty_step']) {
        $qty_content[] = $qty;
    }
    

    The program will try to make up to 400000000 entries in the array, which takes so much memory that PHP can't handle it. So it throws the error you've got. As someones said in your question's comments, try to debug the content of all variables, for example:

    var_dump(
      array('qty' => $qty,
        'min_qty' => $min_qty,
        'max_qty' => $max_qty,
        'product["qty_step"]' => $product['qty_step'])
    );
    

    And see what you get. In all cases, this error means you're taking too much memory, so you must reduce the loop's iterations by increasing $product['qty_step'] or reducing the difference between $min_qty and $max_qty.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器