Fix Fatal Error: Allowed Memory Size Exhausted in PHP

fatal errormemoryPHP

I've seen this error elsewhere, but the general consensus seems to be "Increase the allowed memory PHP has". Ours is already at 1GB, so I'd like to figure out (if possible) what's going wrong here.

The full error is:

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 523800 bytes) in /lib/Zend/Locale/Data.php on line 819

Then, in the Data file mentioned, line 819 is the citytotimezone case:

case 'citytotimezone':
    $_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type');
    foreach($_temp as $key => $found) {
        $temp += self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key);
    }
    break;

This intermittent error just started happening within the last week or so, but we've not made any relevant changes that should be affecting this.

How can I begin to debug this issue?

We are using PHP 5.3.10, if that's relevant.

Best Answer

It's hard to say exactly why that chunk of code is trigging the memory error without more context - a stack trace, description of what actions are ongoing when the error occurs, etc.

But, I can definitely say that by going with a more modern version of PHP you will see decreased memory usage. You could always manually raise the 1GB, but even if you do that you will see more benefit with PHP 5.4 or 5.5. More information on PHP memory here.

What version of Magento are you using? Double check the system requirements here and be sure you meet them all.