[wp-trac] Re: [WordPress Trac] #4045: Large blogs fatal error in cache.php: extreme memory consumption on object reference removal

WordPress Trac wp-trac at lists.automattic.com
Thu Sep 27 14:50:07 GMT 2007


#4045: Large blogs fatal error in cache.php: extreme memory consumption on object
reference removal
------------------------------+---------------------------------------------
 Reporter:  astereo           |        Owner:  anonymous
     Type:  defect            |       Status:  reopened 
 Priority:  high              |    Milestone:  2.4      
Component:  General           |      Version:  2.2      
 Severity:  critical          |   Resolution:           
 Keywords:  5.2 memory_limit  |  
------------------------------+---------------------------------------------
Comment (by Mrasnika):

 Replying to [comment:5 Otto42]:
 > The unserialize/serialize was introduced by [4856] and [4857] to fix
 #3726. The purpose is to remove references inside objects. I can see why
 it's being done, however this method does eat a ton of memory for large
 objects.
 >
 > Perhaps these calls need to be moved closer to the actual problem area
 and out of the general cache functions entirely?

 Exactly, this is how I solved it for my blog. Indeed it is the
 serialize|unserialize routine that eats the memory. I decided the turn off
 the cache by setting DISABLE_CACHE . However, the wp_cache_set() function
 is not aware of it! This is the functions that's on line 48, and that's
 the function that's triggering the fatal error. So, in order to make the
 function aware that the cache has been disabled, I simply copied the
 checks to the function, like this (did the same for wp_cache_replace since
 it also has serialize|unserialize):

 {{{
 function wp_cache_set($key, $data, $flag = '', $expire = 0) {

         if (defined('DISABLE_CACHE'))
                 return;

         if ( ! defined('ENABLE_CACHE') )
                 return;

         global $wp_object_cache;
         $data = unserialize(serialize($data));

         return $wp_object_cache->set($key, $data, $flag, $expire);
 }
 }}}

 In this way, whoever has issues with exhausting the memory, he/she can
 turn the caching off for real, and never execute the serialize|unserialize
 routine.

 What do you think ?

-- 
Ticket URL: <http://trac.wordpress.org/ticket/4045#comment:9>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list