国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

上傳圖片(6M),內(nèi)存溢出(128M)

luhuan

問題描述

上傳的文件只有6M,PHP內(nèi)存設(shè)置的是128M,但是卻提示內(nèi)存溢出

程序代碼

use Intervention\Image\ImageManagerStatic as Image;

$file = $request->file('file');
$image = Image::make($file);//這里內(nèi)存溢出了

報(bào)錯(cuò)信息

pid:12746 Worker[12746] process terminated with ERROR: E_ERROR "Allowed memory size of 134217728 bytes exhausted (tried to allocate 16384 bytes) in /vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php on line 154"

截圖報(bào)錯(cuò)信息里報(bào)錯(cuò)文件相關(guān)代碼

擴(kuò)展154行代碼如下
截圖

操作系統(tǒng)及workerman/webman等框架組件具體版本

linux下的docker容器,php8.0版本,webman版本:1.5.6

1973 2 1
2個(gè)回答

six

phar打包或者二進(jìn)制打包后的文件會(huì)很大,啟動(dòng)后會(huì)進(jìn)程會(huì)占用較高內(nèi)存,上傳個(gè)文件內(nèi)存就可能超限制了。

walkor 打賞

app/controller/UploadController.php

<?php
namespace app\controller;
use support\Request;
use Intervention\Image\ImageManagerStatic as Image;
class UploadController
{

    public function index()
    {
        return '<body>
<form method="post" action="http://127.0.0.1:8877/upload/files" enctype="multipart/form-data" />
<input name="file" multiple="multiple" type="file">
<input type="submit">
</form>';
    }

    public function files(Request $request)
    {
        $s = 'M<br> 起始內(nèi)存占用:' . number_format(memory_get_usage()/(1024*1024), 2);
        $file = $request->file('file');
        $image = Image::make($file);
        return  '文件大小:' . number_format($file->getSize()/(1024*1024), 2) . $s
            . 'M<br> 處理后內(nèi)存占用:' . number_format(memory_get_usage()/(1024*1024), 2)
            . 'M<br> memory_limit:' . ini_get( 'memory_limit');
    }
}

截圖

我本地測試結(jié)果,沒有什么問題

環(huán)境

php -v
PHP 7.4.32 (cli) (built: Sep 28 2022 19:14:45) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
php --ri gd
gd

GD Support => enabled
GD Version => bundled (2.1.0 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.9.1
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 9 compatible
PNG Support => enabled
libPNG Version => 1.6.34
WBMP Support => enabled
XPM Support => enabled
libXpm Version => 30512
XBM Support => enabled
WebP Support => enabled
BMP Support => enabled
TGA Read Support => enabled

Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 1 => 1
composer info | grep image
intervention/image               2.7.2    Image handling and manipulation library with...
  • luhuan 2023-09-20

    老大,我試了還是不行的,上傳了一個(gè)4M多的,內(nèi)存占用將近50M,相比你的測試結(jié)果,內(nèi)存占用很高
    結(jié)果:
    文件大小:4.64M
    起始內(nèi)存占用:9.97M
    處理后內(nèi)存占用:57.15M
    memory_limit:128M

    <?php
    namespace app\api\controller;

    use app\service\CommonService;
    use DI\Attribute\Inject;
    use Intervention\Image\ImageManagerStatic as Image;
    use support\Request;

    class CommonController
    {

    [Inject]

    private CommonService $service;
    
    public function test(Request $request)
    {
        $s = 'M<br> 起始內(nèi)存占用:' . number_format(memory_get_usage()/(1024*1024), 2);
        $file = $request->file('file');
        $image = Image::make($file);
        return  '文件大小:' . number_format($file->getSize()/(1024*1024), 2) . $s
            . 'M<br> 處理后內(nèi)存占用:' . number_format(memory_get_usage()/(1024*1024), 2)
            . 'M<br> memory_limit:' . ini_get( 'memory_limit');
    }

    }

  • walkor 2023-09-20

    php版本?
    Intervention\Image 版本?
    用一個(gè)空的webman項(xiàng)目試下,排除自動(dòng)注入問題。

  • luhuan 2023-09-21

    版本信息:php:8.0,Intervention\Image:2.7.2
    有測試結(jié)果了,用了一個(gè)空的webman測試的。
    在容器中起的服務(wù),上傳文件時(shí)會(huì)占用比較高的內(nèi)存,在主機(jī)上的服務(wù)上傳則是正常的;
    這個(gè)問題有解決的辦法嗎?

年代過于久遠(yuǎn),無法發(fā)表回答
??