switch_to_blog() causing memory leak
-
I am seeing memory leaks with switch_to_blog(), the issue seems to be this:
1. wp_cache_init() is called, GLOBALS[‘wp_object_cache’] in 2MB in size, total memory usage is 22MB.
2. Switch to blog is called
3. wp_cache_init() is called (aswp_cache_switch_to_blog()
is not implemented),$GLOBALS['wp_object_cache']
in 0.5MB in size, total memory is 22.5MBAt this point, total memory should be 21.5MB, however the first WP_Object_cache object is not being garbage collected when the reference in $GLOBALS[‘wp_object_cache’] is set to the new instance of WP_Object_Cache.
Doing this:
for ( $i = 1; $i < 100; $i++ ) { switch_to_blog( 15 ); restore_current_blog(); }
raises memory usage to circa 120MB.
I have tried using
xdebug_debug_zval
to count references to the first instance of WP_Object_Cache, however that is appearing to be only 1 – so I am not sure why this is not being garbage collected.If anyone can replicate this, any advice would be much appreciated!
- The topic ‘switch_to_blog() causing memory leak’ is closed to new replies.