Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php [duplicate]

If your script is expected to allocate that big amount of memory, then you can increase the memory limit by adding this line to your php file

ini_set('memory_limit', '44M');

where 44M is the amount you expect to be consumed.

However, most of time this error message means that the script is doing something wrong and increasing the memory limit will just result in the same error message with different numbers.

Therefore, instead of increasing the memory limit you must rewrite the code so it won’t allocate that much memory. For example, processing large amounts of data in smaller chunks, unsetting variables that hold large values but not needed anymore, etc.

Leave a Comment