Resource not released (ARCH7080)
Ce contenu n’est pas encore disponible dans votre langue.
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.
Incorrect
Section titled “Incorrect”<?phpfunction makeThumb(string $path): string{ $img = imagecreatefromjpeg($path); $out = '/tmp/thumb.jpg'; imagejpeg($img, $out); return $out;}Correct
Section titled “Correct”<?phpfunction 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()).