22850 Posts in 9711 Topics by 2803 members
|Go to End|
27 March 2011 at 12:16am Last edited: 27 March 2011 12:19am
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:
deny from all
This worked for me and hopefully may help others experiencing the same issue, however, may not work for everyone.
10 June 2012 at 11:39pm
Thank you very much ckd , this was a life saver
15 January 2013 at 1:49pm
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!
16 January 2013 at 12:25am
On CPanel hosting I use a similar method, may be of use if SetEnv doesn't work:
16 January 2013 at 2:41am Last edited: 16 January 2013 2:43am
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
|Go to Top|