Search code examples
phpmemory-limit

PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate XX bytes)


Initially, it was stated in the settings of 128MB, then I got this error, I thought that maybe did not have enough memory, then I increased to 256MB, but the error continues.

String in code with this error:

function clean($str) {
$clean_str = stripslashes (trim($str));
return $clean_str;
}

// clean slashes
foreach($result[$i] as $key=>$value) {
 if($key=="currency") continue;
 $result[$i][$key] = clean($result[$i][$key]);
}

Why is this happening ?


Solution

  • Modify your php.ini to increase your memory_limit to something higher than what you have currently provisioned – 512MB is not unusual for modern day applications.