q2a-social-share icon indicating copy to clipboard operation
q2a-social-share copied to clipboard

High Resource Usage- Probably memory leak on PHP 7.0

Open arjunsuresh opened this issue 8 years ago • 5 comments

Hi, I was using this plugin and had no issue until I moved to PHP 7.0 on Ubuntu 16.04. Since then my site was crashing and finally it worked when I uninstalled social-share plugin. Not sure what the issue is as everything is normal on Ubuntu 14.04.

arjunsuresh avatar Oct 15 '16 11:10 arjunsuresh

Were you running on PHP 7 on Ubuntu 14.04 ?

amiyasahu avatar Oct 15 '16 13:10 amiyasahu

Nopes, it was PHP 5.x. But the issue is not there on another Q2A site running on same server. So, I again tried debugging and pinned the problem to this part:

 if (!empty( $image_url ) ) {     
     $image_data = @getimagesize( $image_url );
     $imageOg = new OpenGraphProtocolImage();
     $imageOg->setURL( $image_url );
     $imageOg->setWidth( !empty( $image_data[0] ) ? $image_data[0] : 1200 );
     $imageOg->setHeight( !empty( $image_data[0] ) ? $image_data[0] : 630 );

     if ( !empty( $image_data['mime'] ) ) {
          $imageOg->setType( $image_data['mime'] );
      }
      $ogp->addImage( $imageOg );
}

The @getimagesize function call seem to cause the issue of memory leak but is not happening on another Q2A running on same server. All other plugins are the same too. :O

arjunsuresh avatar Oct 15 '16 22:10 arjunsuresh

Ok. I will take a look on this

amiyasahu avatar Oct 16 '16 08:10 amiyasahu

Thanks..

arjunsuresh avatar Oct 16 '16 09:10 arjunsuresh

@amiyasahu : Can I use the plugin, if the issue is fixed?

rohitagarwal88 avatar Sep 14 '19 08:09 rohitagarwal88