Search code examples
phpmemoryini-set

why does the ini_set('memory_limit') doesn't work?


I am doing a file resizer feature, and when I use very high resolution images, I get this fatal error:

PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to
 allocate 8884 bytes) in /path/resizer.php on line 35

(resizer.php is the resizer class) Then, when I use ini_set('memory_limit', '64MB');

.. in front of the whole block: if (isset($_FILES....)) ... And i get this fatal error:

 PHP Fatal error:  Allowed memory size of 262144 bytes exhausted (tried to 
allocate 8884 bytes) in path/resizerenter code here.php on line 35

Please note that the allocated memory has decreased while I requested an increase. Please let me know if you know what is wrong. Thanks a lot


Solution

  • check the php.ini setting: memory_limit

    Maybe is already more than 64M. In case you can

       ini_set('memory_limit', '128M'); or 256...
    

    Operations with big images can happen to use huge memory!