The function imagedestroy() frees any memory after creating an image with php.
Presumable it frees only the physical memory and not the tmp file that is created every time in linux located in /tmp, or am I wrong?

The thing is, when on a shared hosting with limited space this limit will be reached very quickly when each time there is a tmp file created of ~10kb.

Who need to solve this? Is it a linux host configuration thing? Or isn't doing imagedestroy() a good job? Or do I need clear the /tmp directory myself?

Thansk for all help

    A gd image is created in memory; "imagedestroy()" will free that memory, physical and virtual. If you explicitly put it into a file (e.g. with "imagegd()") then, yes, you'll need to delete that to free the disk space. For the case of an aborted script, see the user notes here for a not completely satisfactory solution.

      This is the basic code, if there is something wrong with it, please let me know.

      header("Content-type: image/gif");
      $image = imagecreatefromgif($url);
      imagealphablending($image, 1);
      imagegif($image);
      imagedestroy($image);
      

      I also tried register_shutdown_function solution but this is not the fact, because when I test I do not stop the script from running by pressing the stop button.

      It is still creating each time two temporary files in /tmp !!

      Any ideas are welcome

        Write a Reply...