【发布时间】:2011-02-09 17:52:06
【问题描述】:
我正在创建循环浏览大量图像的缩略图,当我找到一张大图像时:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 13056 bytes)
现在我已经知道如何规避:
ini_set('memory_limit', '-1');
我想知道的是为什么它会耗尽内存!是否有一些调试工具可以准确显示内存何时耗尽?具体来说,这会告诉我是否有变量/数组正在扼杀我的记忆?
或者,有没有更好的方法来调整图像大小:
$thumb=imagecreatetruecolor($newwidth,$newheight);
$source=imagecreatefromjpeg($imgfile);
imagecopyresampled($thumb,$source,0,0,0,0,$newwidth,$newheight,$width,$height);
imagejpeg($thumb,$destinationfile,85);
?
非常感谢!
【问题讨论】:
-
添加更多内存或处理较小的图像。这是 gdlib 的一个常见问题,这就是我更喜欢 imagemagick 的原因。
标签: php image-processing memory-leaks