2
我运行一个循环,其中包含一个脚本,用于识别图像中的白色背景,然后复制没有白色背景的图像的裁剪版本。在循环结束时,我使用imagedestroy释放内存,但脚本仍然超过内存限制(> 256mb)。 这怎么可能?Imagedestroy不能释放内存
代码内环:
$img = imagecreatefromjpeg($imgSrc);
/* Script for identifying whitespace */
//create new image
$newimg = imagecreatetruecolor(
imagesx($img)-($wsLeft+$wsRight), imagesy($img)-($wsTop+$wsBottom));
//get new width and height
$width = imagesx($newimg);
$height = imagesy($newimg);
//free memory
imagedestroy($newimg);
imagedestroy($img);
PHP是垃圾回收 - 只是因为你在你的代码中销毁一个变量并不意味着内存被立即释放。 [阅读此](http://php.net/manual/en/features.gc.php)了解更多信息。做`$ img = $ newimg = NULL;`可能会有所帮助。 – DaveRandom 2011-12-15 13:36:46