LARAVEL 致命错误异常:允许的 134217728 字节内存大小已用完(尝试分配 10489856 字节)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45952385/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:34:32  来源:igfitidea点击:

LARAVEL Fatal Error Exception : Allowed memory size of 134217728 bytes exhausted (tried to allocate 10489856 bytes)

laravelmemory-limit

提问by skadevz

i want to run this code

我想运行这段代码

$late = Attendance::whereUserType(5)
         ->where('datetime_in', '!=', null)
         ->where(DB::connection('attendance')
         ->raw('DATE(created_at)'), date('Y-m-d'))
         ->orderBy('user_id')->get()->take(10);

but i got an error like in the title said. When i change the memory_limitto 512M, my browser is lag. I'm using 16K+ data for testing, is it ok ?? And what is the problem ??

但我收到了标题中所说的错误。当我将memory_limit更改为 512M 时,我的浏览器滞后。我正在使用 16K+ 数据进行测试,可以吗??还有什么问题??

回答by rikardo_paiva

Try to invert the way you search, changes get()->take(10)to take(10)-> get()

尝试反转搜索方式,更改get()->take(10)take(10)-> get()

回答by Cengkuru Michael

Try to add this on top of the script

尝试将其添加到脚本之上

ini_set('memory_limit','512M');

Your query could be timing out

您的查询可能超时