The test site requires a lot of memory when viewing some category/archive pages.

I met with the following error messages yesterday:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 48 bytes) in /var/www/t/wp-includes/load.php on line 552

Fatal error: Allowed memory size of 209715200 bytes exhausted (tried to allocate 40 bytes) in /var/www/t/wp-includes/meta.php on line 307

The problem was solved by adding the "define('WP_MEMORY_LIMIT', '210M');" line to the wp-config.php file.

But this is not good enough. The production site will have much more data than the test site, which means I have to add the "define('WP_MEMORY_LIMIT', '2100M');" line to the wp-config.php file. And 2100M may not be large enough as the time goes by.

How to decrease the memory consumption of the WordPress site dramatically? Any help is appreciated.

  • Can you give some more details? How many posts per category page do you display? Are your category/archive pages standard or have you modified the theme to do something special? Do you have plugins that do anything with categories? Often when you run into trouble like this it's possible to rethink how it's implemented and not only fix the problem but get significant performance improvement. But we need details...! :) Commented Aug 28, 2010 at 18:18

3 Answers 3


The WordPress Memory is something not easy to deal with. If the standard way is not helping (don't rely on the WP_MEMORY_LIMIT constant, it's conceptually broken, use ini_set in wp-config.php instead), then you can only throw hardware on it or hack the core.

Please check if you're using a recent PHP version on your system. If that's something with PHP 4 upgrade to PHP 5.

If you're running on PHP 5 downgrade to PHP 4 (<- that is for a test and only if any other resort is available. You should consider that bad practice because it will bring you no-where in the near future)

These two advices might sound funny, but I know of both: WP PHP 5 sites that ran out of memory but then worked on PHP 4 and the other way round. Just give it a try.

These are best general tips I can give. The topic is broad, we normally handle that individually.

  • You have "Go PHP5" on your website but you tell him to downgrade to PHP4? Oh the irony. LOL! ;-) Commented Aug 28, 2010 at 18:21
  • 2
    That's real life dialectics.
    – hakre
    Commented Aug 28, 2010 at 19:55
  • Thank you very much. It turns out that the high memory consumption is caused by a file in the current theme.
    – Box
    Commented Aug 29, 2010 at 5:39
  • 2
    Boxoft - how where you able to trace that the high memory consumption was caused by that file ??
    – Tal Galili
    Commented Sep 7, 2010 at 16:50

It might also be a good idea to implement caching. Depending on how often those archives and category pages will be updated, you can save the output in a cache, and only allow it to be updated after say, 15 minutes.

Although you write the high memory consumption was due to a specific file, it can be recommended to cache the more query-heavy pages for high-traffic sites.

  • Thanks for your suggestion. Which WordPress cache plugin(s) do you recommend?
    – Box
    Commented Sep 3, 2010 at 4:54

I'm not sure what your hosting situation is or your performance requirements are, but I saw significant memory usage reductions by switching from Apache2 to lighttpd on my Linux host.

  • Thanks. The high memory consumption is caused by archive.php of the theme. It contains too many database queries. :P
    – Box
    Commented Sep 2, 2010 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.