laravel/telescope

Telescope memory usage grows

开放

#1,593 创建于 2025年5月23日

 (5 条评论) (0 个反应) (0 位负责人)PHP (654 个派生)user submission
help wanted

仓库指标

星标
 (5,187 个星标)
PR 合并指标
 (平均合并 7小时 14分钟) (30 天内合并 6 个 PR)

描述

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.");
    }
}

贡献者指南