Kev*_*ton 3 php memory-leaks image-processing seeding laravel
我正在使用干预图像类进行laravel,并且正在复制,调整图像大小并将图像编码到sites目录.基本上模拟上传到虚假列表.
但是,在运行数据库种子时,我似乎遇到了内存问题.
错误信息:
local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException'
with message 'Allowed memory size of 134217728 bytes exhausted (tried to allocate 5056 bytes)'
in C:\xampp\htdocs\equezone\vendor\intervention\image\src\Intervention\Image\Gd\Decoder.php:115
Run Code Online (Sandbox Code Playgroud)
每张图片不超过1265x625.仅当大于1300x700时,图像才会调整大小.因此,没有图像实际调整大小...
Gd\Decoder.php的第115行
$canvas = imagecreatetruecolor($width, $height);
Run Code Online (Sandbox Code Playgroud)
imagecreatetruecolor 似乎扩展了php的gd类.
这是我的代码的基础知识:
$image = Image::make(( ! is_string($file))? $file->getRealPath(): $file);
if ($image->width() > self::MAX_IMAGE_WIDTH || $image->height() > self::MAX_IMAGE_HEIGHT) {
self::resizeImage($image, self::MAX_IMAGE_WIDTH, self::MAX_IMAGE_HEIGHT);
}
/*
Some code here to retrieve the listing from the database,
create an image in the database
assign image to the listing
*/
$image->encode('jpg',100);
$image->save($img->getImageLocation(), 100);
Run Code Online (Sandbox Code Playgroud)
我找出了内存泄漏的来源.
在内存崩溃之前,种子将播种大约8-14个列表.上传大约60 - 70张图片.然后它耗尽了内存.列表是随机生成的,图像随机分配给列表......
这让我很难过.如果您想了解有关这些信息的更多详细信息,请告诉我们.
完成后,尝试使用destroy释放为实例分配的内存:
$image->encode('jpg',100);
$image->save($img->getImageLocation(), 100);
$image->destroy();
Run Code Online (Sandbox Code Playgroud)
http://image.intervention.io/api/destroy
| 归档时间: |
|
| 查看次数: |
3106 次 |
| 最近记录: |