0

在收到 3000 个寄存器后通过循环运行作业:

允许的内存大小为 134217728 字节已用尽(尝试分配 16384 字节) {"exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 1): 允许的内存大小为 134217728 字节已用尽(尝试分配16384 字节)在 /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117)

我的工作有:public $timeout = 950;

我正在使用带有 php 7.2、Laravel 6、Horizo​​n、Redis、MySql 的 Laradock 环境。

我的设置horizo​​n.php有:

 'memory_limit' => 2048,
 'environments' => [
        'local' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'queue' => ['journey_processing','default','journey_calculations'],
                'balance' => 'false',
                'minProcesses' => 1,
                'maxProcesses' => 1,
                'tries' => 1,
                'delay' => 0,
                'sleep' => 3,
                'timeout' => 420 // Timeout after 7 minutes
            ],
        ],
    ],

我的队列 redis 设置:

'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
            'queue' => 'default',
            'retry_after' => 2990,
            'block_for' => null,
        ],

我关于内存的 php 信息:

我的 PHP 信息

我的 docker 环境内存。 我的 docker 桌面

4

1 回答 1

1

我找到了解决方案。我记得我安装了望远镜,然后,工作中的内存问题就开始了。所以我在检查工作日志,看到了这个:

[2019-09-19 09:55:12][3449] Processing: App\Jobs\CreateJourney

   Symfony\Component\Debug\Exception\FatalErrorException  : Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes)

  at /var/www/vendor/laravel/telescope/src/Storage/DatabaseEntriesRepository.php:145
    141|         $table = $this->table('telescope_entries');
    142| 
    143|         $entries->chunk($this->chunkSize)->each(function ($chunked) use ($table) {
    144|             $table->insert($chunked->map(function ($entry) {
  > 145|                 $entry->content = json_encode($entry->content);
    146| 
    147|                 return $entry->toArray();
    148|             })->toArray());
    149|         });


   Whoops\Exception\ErrorException  : Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes)

  at /var/www/vendor/laravel/telescope/src/Storage/DatabaseEntriesRepository.php:145
    141|         $table = $this->table('telescope_entries');
    142| 
    143|         $entries->chunk($this->chunkSize)->each(function ($chunked) use ($table) {
    144|             $table->insert($chunked->map(function ($entry) {
  > 145|                 $entry->content = json_encode($entry->content);
    146| 
    147|                 return $entry->toArray();
    148|             })->toArray());
    149|         });

  Exception trace:

  1   Whoops\Run::handleError("Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes)", "/var/www/vendor/laravel/telescope/src/Storage/DatabaseEntriesRepository.php")
      /var/www/vendor/filp/whoops/src/Whoops/Run.php:433

  2   Whoops\Run::handleShutdown()

我卸载了 Laravel Telescope,它现在可以像以前一样工作了。我希望这对任何人都有帮助。

于 2019-09-19T11:21:29.197 回答