laravel/telescope

Telescope memory usage grows

Open

#1,593 opened on 2025年5月23日

GitHub で見る
 (5 comments) (0 reactions) (0 assignees)PHP (5,187 stars) (654 forks)user submission
help wanted

説明

Telescope Version

5.7

Laravel Version

12.14.1

PHP Version

8.4

Database Driver & Version

No response

Description

When running a command that inserts or updates a massive number of rows using DB::updateOrInsert, Laravel Telescope causes memory usage to explode beyond 1GB. Without Telescope, memory stays stable (~20MB). With Telescope enabled, memory keeps growing until the process eventually crashes.

Is this the intended behavior of Telescope? It’s quite tricky — I spent several hours debugging before realizing that it was Telescope consuming all the memory.

If this behavior is intentional, maybe a warning could be added to the official Laravel documentation? It’s not uncommon to handle large amounts of data, even during development...

Thanks again for this great package!

Steps To Reproduce

Add this command and run it with php artisan test:eloquent-memory

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class TestEloquentMemory extends Command
{
    protected $signature = 'test:eloquent-memory';
    protected $description = 'Test memory usage of updateOrInsert over 1 million rows';

    public function handle()
    {
        $this->info("Creating table if not exists...");

        DB::statement("
            CREATE TABLE IF NOT EXISTS test_memory (
                id BIGINT PRIMARY KEY,
                updated_at TIMESTAMP NULL
            )
        ");

        $this->info("Starting inserts...");

        for ($i = 1; $i <= 1_000_000; $i++) {
            DB::table('test_memory')->updateOrInsert(
                ['id' => $i],
                ['updated_at' => now()]
            );

            if ($i % 1000 === 0) {
                $memory = round(memory_get_usage() / 1024 / 1024, 2);
                $peak = round(memory_get_peak_usage() / 1024 / 1024, 2);
                $this->line("{$i} rows - Memory: {$memory} MB | Peak: {$peak} MB");
            }
        }

        $this->info("Done.");
    }
}

コントリビューターガイド