Welcome Guest, Not a member yet? Register   Sign In
Getting 500 errors on live site - seems to be a memory allocation issue?
#1

[eluser]mattpointblank[/eluser]
Hi all,

On my local (Windows) server, my 'edit article' page loads fine. On the remote (Linux) server, it gives a blank page, with Firebug reporting a 500 error.

Other 'edit article' pages work, but a few articles (with no obvious pattern) seem to break it.

I looked in the server error log and found this:

Code:
[Mon Apr 12 13:46:34 2010] [error] [client 213.123.176.33] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 1021684 bytes) in /var/www/vhosts/mysite.co.uk/httpdocs/system/libraries/Output.php on line 92, referer: http://www.mysite.co.uk/article/14379

I looked up the function in Output.php, it's this:

Code:
function append_output($output)
    {
        if ($this->final_output == '')
        {
            $this->final_output = $output;
        }
        else
        {
            $this->final_output .= $output;
        }
    }

I recently modified my site so that all HTML loaded from views is concatenated into a string, which is then sent to a 'master' view (basically so I can use the same view for each page). Could this function be related to the error? It seems to only happen on 'rich' pages (eg my 'edit article' page has some WYSIWYG text editors and lots of javascript functions). Any ideas?
#2

[eluser]rogierb[/eluser]
It looks like you have a memory_limit of 32MB in your php.ini. You need to set it to at least 110MB according to the error.

There are a few ways to exhaust memory, like extensive concatenating, recursive functions and processing images.
#3

[eluser]mattpointblank[/eluser]
Thanks for the tip. I wasn't too keen on upping the memory limits so instead enabled CI's output profiler. One of my queries was taking almost a second to complete (fetching 17,000 rows from a table to populate a dropdown list), so I changed it to an AJAX autocomplete instead which not only fixed the error but improved pageload speed too.




Theme © iAndrew 2016 - Forum software by © MyBB