Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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...! :) –  MikeSchinkel Aug 28 '10 at 18:18
add comment

3 Answers 3

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.

share|improve this answer
    
Thanks for your suggestion. Which WordPress cache plugin(s) do you recommend? –  Box Sep 3 '10 at 4:54
add comment

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.

share|improve this answer
    
Thanks. The high memory consumption is caused by archive.php of the theme. It contains too many database queries. :P –  Box Sep 2 '10 at 6:46
add comment

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.

share|improve this answer
    
You have "Go PHP5" on your website but you tell him to downgrade to PHP4? Oh the irony. LOL! ;-) –  MikeSchinkel Aug 28 '10 at 18:21
2  
That's real life dialectics. –  hakre Aug 28 '10 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 Aug 29 '10 at 5:39
2  
Boxoft - how where you able to trace that the high memory consumption was caused by that file ?? –  Tal Galili Sep 7 '10 at 16:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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