'imagecreatefromstring memory leak
Hi I am having an error Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 21944 bytes) when trying to use imagecreatefromstring
$imageFile = imagecreatefromstring($image);
if ($imageFile !== false) {
$width = ImageSX($imageFile);
$height = ImageSY($imageFile);
}
if ($this->isExifInstalled) {
@$type = exif_imagetype($source);
$mime = image_type_to_mime_type($type);
}
if ($mime === "application/octet-stream") {
$mime = $this->image_file_type_from_binary($image);
}
if ($mime === "application/octet-stream") {
$mime = $this->getMimeTypeFromUrl($source);
}
imagedestroy($imageFile);
Solution 1:[1]
Extending the memory limit from available to double did the job, but the problem seems to be with the method "imagecreatefromstring" there must be an issue causing exhaust or false error.
can modify php.ini "memory_limit" or use ini_set("memory_limit","512M");
ini_set is preferable as using that you can identify the memory usage in future, better explore the reason how can the code be optimized without unnecessarily exceeding the limit.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | danronmoon |
