I’ve battled with Elegant Themes and WPEngine over this issue now for the past 2 weeks, and I’m getting absolutely nowhere with either of them.

Here is just one of the errors from the log:

[Wed Apr 26 20:37:29.797099 2017] [:error] [pid 9802] [client 192.104.203.89:55604] PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 218817933 bytes) in /nas/content/live/amberrein/wp-content/plugins/monarch/monarch.php on line 4279, referer: http://www.amberreinhardt.com/category/weddings/

I’ve already upped the memory limit via wp-config.php:

define( 'WP_MEMORY_LIMIT', '1024M' );
define( 'WP_MAX_MEMORY_LIMIT', '1024M' );

It’s very hit or miss with the memory leak. Some blog posts are fine, while others are not. Then, I go back to visit a working post, and then it’s not loading because of the leak, so for whatever reason, it changes or something. I don’t know. And the memory leak amount is always different, but never higher than what I have the limit set to. But, it also seems that the higher the limit, the longer it takes for a post to load if it does load, which is strange.

here is the entire function that i believe is causing the error. line 4279 starts with $content:

function display_media( $content ) {
$monarch_options = $this->monarch_options;

if ( $this->check_applicability( $monarch_options[ 'sharing_media_post_types' ], 'media' ) ) {
    preg_match_all( '/<img [^>]*>/s', $content, $images_array );
    foreach ( $images_array[0] as $image ) {
        if ( false !== strpos( $image, 'class="ngg_' ) ) {
            continue;
        }

        preg_match( '@src="([^"]+)"@' , $image , $image_src );

        $icons       = $this->generate_media_icons( $image_src[1] );
        $replacement = '<div class="et_social_media_wrapper">' . $image . $icons . '</div>';
        $content     = str_replace( $image, $replacement, $content );
    }
}

return $content;

}

What can I do to resolve this issue, since Elegant Themes and WPEngine are no help? I don’t want to have to disable the plugin as the client wants to keep it.

Read more here: Memory Leak issue with Monarch social sharing plugin


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: