Jump to:

23483 Posts in 18976 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Fatal Error: Allowed Memory Size - Helpful Tip

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 3092 Views
  • ckd
    Community Member
    18 Posts

    Fatal Error: Allowed Memory Size - Helpful Tip Link to this post


    I experienced this error after a recent install of SilverStripe and thought I would post some tips here in case others experience the same issue:

    From my experience, this error occurs when the PHP memory on your server is too low. Quite often, even after you change the memory limit, this message can still persist. In my case, after seeing the SilverStripe warning, on install, that my memory was too low, I contacted my hosting provider who increased the limit to 128M from 32M. Once they made these changes, I found that a php.ini file was now in the root directory containing the following:

    memory_limit = 128M

    I reinstalled SilverStripe, (no warnings this time), and all was well until I added my first module, in this case DataObjectManager. Everything looked ok on the front end of the site, after doing a dev build and flush, however when I went back to the admin I received a blank page with the dreaded "Fatal error: Allowed memory size of 33554432 bytes exhausted..."

    So I was a bit perplexed as to why, after increasing the memory size, that I was receiving this error message.

    When you see this error, look at the number ie amount of bytes, in my case '33554432' and divide by 1024 then divide again by 1024 = 32. So, even though you have increased the limit to say 128M, you can still see that SS is recognising only 32M of available memory.

    Next step is to check that you have indeed increased the memory limit. Grab you text editor and add the following code:


    then save the file as phpinfo.php

    Upload this file to the root directory of your server and open the page ie

    You should now be able to view your php settings. Scroll down until you find 'memory_limit' and check to see if it is correct and that it has been indeed been increased to the desired amount. You will probably find that it has been.

    Now, create a folder in your root directory ie 'temp' and re upload phpinfo.php to that folder and then open in your browser ie

    Checking the memory_limit setting, you may see here that it still reflects 32M. From this we can deduce that having increased the memory limit with your hosting provider, it only has affected the root directory of the site and not all directories.

    To change this, open your htaccess file and add the following:

    SetEnv PHPRC "/home/mysite/public_html/"

    The path is the location to your php.ini file. Now open the phpinfo.php file from the temp folder again, refresh your browser, you should now see that the memory limit has been increased. Hence, memory limit across all folders should now be at the desired amount ie 128M.

    I put my php.ini file within the cgi-bin and changed the path in htaccess to reflect this. You also want to the following in your htaccess file:

    <Files php.ini>
    order allow,deny
    deny from all

    This worked for me and hopefully may help others experiencing the same issue, however, may not work for everyone.

  • Mindfusion
    Community Member
    7 Posts

    Re: Fatal Error: Allowed Memory Size - Helpful Tip Link to this post

    Thank you very much ckd , this was a life saver

  • figjam
    Community Member
    10 Posts

    Re: Fatal Error: Allowed Memory Size - Helpful Tip Link to this post

    Thanks for the excellent explanation about modifying the ".htaccess" to order for a top level "php.ini" to work...

    Previously I'd been placing my "php.ini" in my "framework" (sapphire) directory and keep having to remember to put it back after each upgrade!

  • feejin
    Community Member
    22 Posts

    Re: Fatal Error: Allowed Memory Size - Helpful Tip Link to this post

    On CPanel hosting I use a similar method, may be of use if SetEnv doesn't work:

    suPHP_ConfigPath /PATH/TO/php.ini


    suPHP_ConfigPath /wwwdata/username/public_html/php.ini

  • DesignerX.com.au
    Community Member
    107 Posts

    Re: Fatal Error: Allowed Memory Size - Helpful Tip Link to this post

    Another way which solved this problem for me on 2 different hosting provider (CrazyDOmain.com.au & another one, cant remember it ) .
    Add a php.ini with the new memory limit in the framework/ folder ! yes , after hours of test this worked .
    BTW, I only have problems on hosting provided by clients, my VPS with HostGator works perfect .

    Edit: @figja , I just read your post . I can imagine how much trail & error it took to solve it

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.