<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model;
class TestMemoryLeak extends Command
{
protected $signature = 'test:memoryleak';
protected $description = 'Tests the memory leak that appears since 5d9b363448b9aac83b610166141b8bba9f1807f8';
private $article;
public function __construct(Article $article)
{
parent::__construct();
$this->article = $article;
}
public function handle()
{
for($i = 0; $i < 50000; $i++) {
$article = new $this->article;
$article->id = $i;
$article->{$article->getUpdatedAtColumn()} = $article->{$article->getCreatedAtColumn()} = $article->freshTimestampString();
}
$this->info('used ' . round(memory_get_peak_usage() / 1024 / 1024, 1) . ' MB RAM');
}
}
class Article extends Model {}