Fatal error: Out of memory, but I do have plenty of memory (PHP)

前端 未结 20 2554
情歌与酒
情歌与酒 2020-11-29 23:34

Since my question is getting longer and longer, I decide to re-write the whole question to make it better and shorter.

I run my website on dedicated server with 8GB

相关标签:
20条回答
  • 2020-11-30 00:22

    I had a similar problem with PHP:

    1) Check your error logs. Eliminate EVERY error before continuing. 2) Consider modifying your apache configuration to eliminate unused modules - this will reduce the footprint needed by PHP - here's a great link for this - it's specific to Wordpress but should still be very useful http://thethemefoundry.com/blog/optimize-apache-wordpress/

    To give you an idea of the kind of bug I found, I had some code that was trying to post content to Facebook, Facebook then modified their API so this broke, I also used a 'content expirator' which basically meant that it kept retrying to post this content to Facebook and leaving loads of objects lying in memory.

    0 讨论(0)
  • 2020-11-30 00:24

    I would guess that you either haven't edited the right php.ini or you haven't restarted PHP and/or the webserver.

    Create a phpinfo.php page in your docroot with the contents <?php phpinfo(); to make sure you are changing the correct php.ini. In addition to the location of the php.ini file the webserver is using, it will also state the maximum script memory allowed.

    Next, I would add some stack traces to your page so you can see the chain of events that led to this. The following function will catch fatal errors and provide more information about what happened.

    register_shutdown_function(function()
    {
        if($error = error_get_last())
        {
            // Should actually log this instead of printing out...
            var_dump($error);
            var_dump(debug_backtrace());
        }
    });
    

    Personally, Nginx + PHP-FPM is what I have used for years since I left slow ol' Apache.

    0 讨论(0)
提交回复
热议问题