$model = new static((array) $attributes); 内存超出

huangyan

问题描述

访问时,内存超出,报错
process terminated with ERROR: E_ERROR "Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /www/wwwroot/cj.lianhezhaopin.com/vendor/illuminate/database/Eloquent/Model.php on line 496"

process terminated with ERROR: E_ERROR "Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /www/wwwroot/cj.lianhezhaopin.com/vendor/illuminate/database/Eloquent/Model.php on line 522"
Model文件报错

程序代码或配置

public function newInstance($attributes = [], $exists = false)
    {
        // This method just provides a convenient way for us to generate fresh model
        // instances of this current model. It is particularly useful during the
        // hydration of new objects via the Eloquent query builder instances.
        $model = new static((array) $attributes);

        $model->exists = $exists;

        $model->setConnection(
            $this->getConnectionName()
        );

        $model->setTable($this->getTable());

        $model->mergeCasts($this->casts);

        return $model;
    }

    /**
     * Create a new model instance that is existing.
     *
     * @param  array  $attributes
     * @param  string|null  $connection
     * @return static
     */
    public function newFromBuilder($attributes = [], $connection = null)
    {
        $model = $this->newInstance([], true);

        $model->setRawAttributes((array) $attributes, true);

        $model->setConnection($connection ?: $this->getConnectionName());

        $model->fireModelEvent('retrieved', false);

        return $model;
    }

重现问题的步骤

重启服务后,然后多次访问之后,就会出现上面的错误

操作系统环境及workerman/webman等具体版本

"php": ">=7.2",
"workerman/webman-framework": "^1.5.0",
"monolog/monolog": "^2.0",
"webman/admin": "0.5.0",
"endroid/qrcode": "^4.3",
"endroid/qr-code": "^4.3",
"overtrue/pinyin": "^4.0",
"workerman/crontab": "^1.0",
"phpoffice/phpspreadsheet": "^1.28",
"webman/redis-queue": "^1.2",
"workerman/redis": "^1.0.4"

494 0 0
0个回答

年代过于久远,无法发表回答
×
🔝