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

waki picture waki · Dec 10, 2013 · Viewed 25.8k times · Source

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 ?

Answer

zeantsoi picture zeantsoi · Dec 10, 2013

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.