This message means one PHP request tried to hold more in memory than it is allowed. The limit is per request, not per server: a 256M limit does not mean the server has 256M.

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

134217728 is 128M. The number in the message is always the current limit, so you never have to look it up.

Where to raise it

  • EGPNL - PHP settings for the site, which is the right place because it survives updates.
  • php.ini - memory_limit = 256M, for the whole pool.
  • wp-config.php - define("WP_MEMORY_LIMIT", "256M"); for WordPress alone.
A limit above 512M is nearly always hiding a bug. Reading a whole table into an array, or a whole file instead of streaming it, needs fixing rather than feeding.

Find what is eating it

echo round(memory_get_peak_usage(true)/1048576, 1) . ' MB';

Put that at the end of the slow page and it prints the peak. Then bisect: comment out half the work and watch which half the peak follows.

The two usual causes

  • An unbounded query. SELECT with no LIMIT on a table that has grown. Page through it.
  • An image library on a large file. A 6000px photograph costs far more in memory than its file size suggests, because it is uncompressed once loaded.
A cron job that fails at 128M and works at 512M has not been fixed. It will fail again when the data grows, at three in the morning.