这个页面会导致内存泄漏吗


Will this page cause memory leak?

我在下面有一个页面,它为用户加载了一个图像,url看起来像someurl/page.php?路径=.jpg当人们访问这个页面时,我发现内存使用量增加得很快我不确定这个页面是否会导致内存泄漏

 <?php
    $tar_path=urldecode($_GET['path']); 
    $strs=preg_split("/'./",$tar_path); 
    $small_name = $strs[0].'_small.'.$strs[1]; 
    header('Content-type: image/jpeg'); 
    if(file_exists($small_name))
    {
        $PSize = filesize($small_name );
        $picturedata = fread(fopen($small_name, "r"), $PSize);
        echo $picturedata;
    }else
    {
        $im = imagecreatefromjpeg($tar_path);  
        $maxwidth = 150;  
        $maxheight = 0; 
        $pic_width = imagesx($im);  
        $pic_height = imagesy($im);  

        $widthratio = $maxwidth/$pic_width;  
        $resizewidth_tag = true;  

        $ratio = $widthratio;  
        $newwidth = $pic_width * $ratio;             
        $newheight = $pic_height * $ratio;         
        if(function_exists("imagecopyresampled"))  
        {  
            $newim = imagecreatetruecolor($newwidth,$newheight);   
            imagecopyresampled($newim,$im,0,0,0,0,$newwidth,$newheight,$pic_width,$pic_height);   
        }  
        else  
        {  
            $newim = imagecreate($newwidth,$newheight);  
            imagecopyresized($newim,$im,0,0,0,0,$newwidth,$newheight,$pic_width,$pic_height);  
        }  
        imagejpeg($newim,$small_name);  
        imagedestroy($newim);  
        imagedestroy($im);
        $PSize = filesize($small_name );
        $picturedata = fread(fopen($small_name, "r"), $PSize);
        echo $picturedata;
    }         
    ?>  

浏览器或服务器的内存使用情况?。

php解释器应该在脚本执行结束后释放所有内存。在这种情况下,服务器上的内存消耗增加可能表明处理图像的工作量很大,但完成后应释放所有内存。