0

Laravel v5.6. Using basic Homestead setup. Laravel seeder throws "Allowed memory size of .. bytes exhausted". Not a query log issue. Tried removing non-default providers. Tried switching to production and disabling debugging. Memory leaks even after simplifying seeder (users table is not empty):

<?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());
    }
}

Outputs:

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
(
)

How can I proceed with debugging this issue? Thanks.

EDIT NOT A DUPLICATE - raising memory_limit is not solution.

Be Kind
  • 4,712
  • 1
  • 38
  • 45
  • How do you run that code? Are you sure that raising the memory limit higher than 11 MB is not a solution? The current default value is 128 MB – Nico Haase Apr 04 '18 at 14:19
  • Run using php artisan db:seed --class=UsersTableSeeder. No, raising the limit is never a solution if there's a memory leak. Turns out it's a problem with homestead. – Be Kind Apr 04 '18 at 14:24

1 Answers1

2

This is a Homestead issue: https://github.com/laravel/homestead/issues/825

Update Homestead or use php7.1 artisan ....

Jonas Staudenmeir
  • 24,815
  • 6
  • 63
  • 109