Memory leak in WP_Query
-
Running WordPress 5.8.3
I have a site hosted on WPEngine, PHP memory limit set to their max of 512MB. I have a custom plugin that creates a custom post type, and it’s definitely not my first plugin doing this. This one has the exception of using ACF, and most of the fields are from ACF, including Flexible Content. We developed on this site for months, using it the whole time with no issues. Within 24 hours of switching it over to the production domain (that’s all we did, changed domains), it started crashing. About once a day. No errors in the logs except “PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 1470464 bytes) in /nas/content/live/caboluxury/wp-includes/wp-db.php on line 2022”.
The pages with this shortcode crash (500 white screen of death) after that memory error. If I deactivate ANY plugin, it clears the memory issue and fixes the 500 page crashes, until the memory creeps up again and crashes those pages again. I can reactivate that plugin and it has no effect either way.
I created a staging clone of the site. The only difference is a different domain name. I can’t get this to reproduce on that cloned site, and it never happened on the production site until we changed the domain name to [ redundant link removed ].
I watch as the WP_Query in my shortcode on the [ redundant link removed ] results in higher and higher peak usage (memory_get_peak_usage() both emalloc and real called after wp_reset_postdata()). But, this doesn’t happen on the cloned site, nor did it happen before we switched the original site to the production domain name.
It acts like memory leak, but I would expect that leak to be reproduced on the clone as well.
Any help with debugging is MUCH appreciated, as the client is furious and I’m banging my head against a wall trying to figure this out. It’s the weirdest thing I’ve ever seen.
Here’s my logging of memory usage before and after WP_Query. The first link is the production site, the second is the clone. It’s ongoing, so you can watch it if you keep refreshing:
https://www.caboluxury.com/wp-content/plugins/rlp-caboluxury/rlp_caboluxury_log.txt https://caboluxury1stg.wpengine.com/wp-content/plugins/rlp-caboluxury/rlp_caboluxury_log.txt
- This topic was modified 3 years ago by . Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
The page I need help with: [log in to see the link]
- The topic ‘Memory leak in WP_Query’ is closed to new replies.