تخطَّ إلى المحتوى

Resource not released (ARCH7080)

هذا المحتوى غير متوفر بلغتك بعد.

Key php.performance.disposable-not-disposed · Severity warning · Category performance

A resource (e.g. a GD image handle) is opened but never released, leaking memory and OS handles. Free it explicitly when work is done.

<?php
function makeThumb(string $path): string
{
$img = imagecreatefromjpeg($path);
$out = '/tmp/thumb.jpg';
imagejpeg($img, $out);
return $out;
}
<?php
function makeThumb(string $path): string
{
$img = imagecreatefromjpeg($path);
$out = '/tmp/thumb.jpg';
imagejpeg($img, $out);
imagedestroy($img);
return $out;
}

Release resource-owning objects when done with their dedicated free call (e.g. imagedestroy()).