1 :print_script_block_data in wp_print_footer_scripts destroys memory usage
-
Running on WP 3.7
TLDR: 1 :print_script_block_data is generating 324MB extra peak memory in my setup of 338 categories.if i list wp_print_footer_scripts ‘s hooked functions, I get the following:
-1 Jetpack:implode_frontend_css
1 :print_script_block_data
5 :localize_printed_scripts
9 CJTBlocksCouplingController:linkFooterStyleSheets
10 _wp_footer_scripts
10 QM_Collector_Assets_Scripts:action_print_footer_scripts
10 QM_Collector_Assets_Styles:action_print_footer_scripts
10 log_memory_usageIf I tap in at wp_print_footer_scripts with priority -2, 0, 2, 6, 9 and record memory_get_usage and memory_get_peak_usage this is what I get:
<br />wppfs @ -2 memory_get_usage=28MB
<br />wppfs @ -2 memory_get_peak_usage=28MB
<br />wppfs @ 0 memory_get_usage=28MB
<br />wppfs @ 0 memory_get_peak_usage=28MB
<br />wppfs @ 2 memory_get_usage=34MB
<br />wppfs @ 2 memory_get_peak_usage=358MB
<br />wppfs @ 6 memory_get_usage=34MB
<br />wppfs @ 6 memory_get_peak_usage=358MB
<br />wppfs @ 9 memory_get_usage=34MB
<br />wppfs @ 9 memory_get_peak_usage=358MBTherefore this means that 1 :print_script_block_data is generating 324MB extra peak memory.
Query monitor reports 177 queries in total being done when this action is active.
Removing this action drops the extra peak memory, here is a report of memory usage in wp_print_footer_scripts at priority -2, 0, 2, 6, 9 after removal:
<br />wppfs @ -2 memory_get_usage=33MB
<br />wppfs @ -2 memory_get_peak_usage=33MB
<br />wppfs @ 0 memory_get_usage=33MB
<br />wppfs @ 0 memory_get_peak_usage=33MB
<br />wppfs @ 2 memory_get_usage=33MB
<br />wppfs @ 2 memory_get_peak_usage=33MB
<br />wppfs @ 6 memory_get_usage=33MB
<br />wppfs @ 6 memory_get_peak_usage=33MB
<br />wppfs @ 9 memory_get_usage=33MB
<br />wppfs @ 9 memory_get_peak_usage=33MBSite has 338 categories in wc_product_block_data
The fix was
add_action( 'wp_head', 'fix_memory_leak' ); function fix_memory_leak(){ remove_all_actions('wp_print_footer_scripts', 1); remove_all_actions('admin_print_footer_scripts', 1); }However this might be removing additional actions hooked at priority 1. I wasn’t able to remove the action via it’s name.
The topic ‘1 :print_script_block_data in wp_print_footer_scripts destroys memory usage’ is closed to new replies.