Laravel v5.6。 使用基本的Homestead设置。 Laravel播种机抛出“允许的内存大小......字节耗尽”。不是查询日志问题。尝试删除非默认提供程序。尝试切换到生产并禁用调试。即使简化了播种器(用户表不为空),内存也会泄漏:
<?php
use Illuminate\Database\Seeder;
use App\User;
class UsersTableSeeder extends Seeder
{
public function run()
{
// $users = factory(App\User::class, 1)->create();
for ($i = 1; $i <= 10; $i++) {
$user = User::first();
$user = null;
print("Memory usage: ". memory_get_usage() ."\r\n");
}
print("________________________________________\r\n");
print("TEST FINISHED\r\n");
print("Memory usage: ". memory_get_usage() ."\r\n");
print("Query log: ");
print_r(DB::getQueryLog());
}
}
输出:
Memory usage: 11503280
Memory usage: 11514592
Memory usage: 11525872
Memory usage: 11537152
Memory usage: 11548432
Memory usage: 11559712
Memory usage: 11570992
Memory usage: 11582272
Memory usage: 11593552
Memory usage: 11604832
________________________________________
TEST FINISHED
Memory usage: 11604832
Query log: Array
(
)
如何继续调试此问题?感谢。
修改 不是DUPLICATE - 提高memory_limit不是解决方案。
答案 0 :(得分:2)
这是Homestead问题:https://github.com/laravel/homestead/issues/825
更新Homestead或使用php7.1 artisan ...
。