允许的内存大小为 134217728 字节耗尽(尝试分配 20480 字节)Laravel
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51152078/
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
Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) Laravel
提问by Mostafa Norzade
I have a problem with Laravel . after restart my system, My project will not run !!!
我对 Laravel 有问题。重新启动我的系统后,我的项目将无法运行!!!
I run with php artisan serv
, but I have below messages in console :
我用 运行php artisan serv
,但控制台中有以下消息:
[Tue Jul 3 14:31:35 2018] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /laravel-projects/blog/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 122
[Tue Jul 3 14:31:35 2018] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /laravel-projects/blog/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 46
[Tue Jul 3 14:31:38 2018] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /laravel-projects/blog/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 122
[Tue Jul 3 14:31:39 2018] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /laravel-projects/blog/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 46
[Tue Jul 3 14:31:39 2018] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /laravel-projects/blog/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 122
Before the system was restored, the project was well implemented !!
系统恢复前,项目执行良好!!
回答by Alihossein shahabi
This means you need to also update your php.inimemory_limit
directive.
这意味着您还需要更新php.inimemory_limit
指令。
Try put in your php.ini :
尝试放入你的 php.ini :
memory_limit=1024Mand restart apache:
memory_limit=1024M并重启apache:
sudo systemctl restart httpd.service
sudo systemctl restart httpd.service
回答by Harshavardhan
Change in php.ini
which is there inside apache2
folder
变化php.ini
是有内部apache2
的文件夹
memory_limit=1024M
restart apache2
you can even check which php ini config is using by:
您甚至可以通过以下方式检查正在使用的 php ini 配置:
php -i | grep "php.ini"
回答by NaramukAbus
This problem occurs when an application uses more memory than PHP allows. thanks to PHP's relatively conservative default memory settings. you can fix this issue by change memory_limit size in your php.ini
当应用程序使用的内存超过 PHP 允许的内存时,就会出现此问题。感谢 PHP 相对保守的默认内存设置。您可以通过更改 php.ini 中的 memory_limit 大小来解决此问题
memory_limit= Replace your size(1024M /2048M/etc)change and save it, then restart the services.
memory_limit= 替换您的大小(1024M /2048M/etc)更改并保存,然后重新启动服务。
In window you can find "C:\wamp64\bin\php\php_version\php.ini" then restart your service.
Ubuntu you can find "/etc/php/php_version/apache2/php.ini" then run
sudo systemctl restart apache2
for restart apache.
在窗口中,您可以找到“C:\wamp64\bin\php\php_version\php.ini”,然后重新启动您的服务。
Ubuntu你可以找到“/etc/php/php_version/apache2/php.ini”然后运行
sudo systemctl restart apache2
重启apache。
You can simply increase the memory limit programmatically early on in your code, before your process runs out of memory. If you do it this way, you can give PHP extra memory only when that piece of code gets called rather than increasing the memory limit for all PHP processes.
在您的进程内存不足之前,您可以在代码的早期以编程方式简单地增加内存限制。如果你这样做,你可以只在调用那段代码时给 PHP 额外的内存,而不是增加所有 PHP 进程的内存限制。
ini_set('memory_limit', '1024M');