Decreasing the Memory Consumption of a WordPress Site?

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

I met with the following error messages yesterday:

Read More

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.

Related posts

Leave a Reply

3 comments

  1. 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.

  2. 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.

  3. 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.