Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

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

memory limit exhausted with larger number of assets


Go to End
Reply

9 Posts   75812 Views

Avatar
Anatol

29 November 2007 at 5:19pm 126 Posts

Hi,

I created a Silverstripe site and currently I am adding content to it. I now have about 300 pictures in the assets folder (no giant file sizes, approximately about 20K average file size - 7 MB all files in total - and no file larger than 100K). If I upload just a few more images (via FTP) and I then open the "assets" tab in the CMS to let Silverstripe know that these files exist I get a "Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 46289 bytes)".

I am on a virtual private server and it seems that I cannot allocate more than 32MB to PHP.

It seems the memory_limit problem comes from the number of files, not from particularly large files. Did anyone else have this problem? Is there any workaround or any way to split the execution of the script into smaller chunks so the memory limit does not get exhausted?

The site I am working on is basically ready to go live, but now I am stuck because I cannot add more content.

Nevertheless: thank you for the hard work and efforts you all put into Silverstripe.

Any hints to solve this problem would be highly appreciated.

Cheers!
Anatol

Avatar
Sigurd

29 November 2007 at 7:40pm Forum Moderator, 628 Posts

Are you certain that you cannot set a higher php memory limit in an .htaccess file, or in php as a n ini_set() call?

Avatar
Anatol

29 November 2007 at 8:49pm 126 Posts

Hi Sigurd,

yes, you are right! I can change the PHP memory_limit in any way: ini_set(), .htaccess, and also in php.ini - I just forgot that for some reason my _config.php file had the line

ini_set('memory_limit', '32M');

So whatever memory limit I specified it was reset to 32MB... I don't get a fatal error any more now. Thank you so much to point me to the right direction.

It may still be worth noting that a lot of pictures/files in the assets folder require an increased PHP memory_limit. Do you have any experience what happens when you have heaps more, say 10,000+ images or other media files in the assets folder? Do I have to adjust my memory_limit with the number of uploaded files? It makes sense that the more PHP code I use the more the memory usage increases, but I did not expect that the number of uploaded files could have that effect. But maybe the amount of PHP code that I use on my site is at a critical level close to the 32MB memory limit.

Again, thank you very much for your help! Silverstripe is awesome!

Cheers!
Anatol

Avatar
Sigurd

29 November 2007 at 9:39pm Forum Moderator, 628 Posts

Ultimately, we should look into reducing memory consumption here; could you please add this as a ticket at http://open.silverstripe.com/newticket (you will need to visit http://open.silverstripe.com/register if you've not registered), and this item will be properly itemised and dealt with ;)

Paste the URL of the ticket back here once done...

Avatar
Anatol

29 November 2007 at 10:11pm 126 Posts

I added a ticket for this issue ([url=http://open.silverstripe.com/ticket/1929]#1929[/url])

Avatar
Sigurd

29 November 2007 at 10:17pm Forum Moderator, 628 Posts

Thanks :)

Avatar
streetdaddy

28 January 2008 at 9:00pm 32 Posts

I experienced this same problem, however due to some configuration of my host I didn't get any error, just a blank page when trying to view the Files & Images tab in the CMS.

I was able to get it fixed by increasing the memory limit in _config.php:

ini_set('memory_limit', '64M');

Avatar
Anatol

28 January 2008 at 9:29pm 126 Posts

Hi streetdaddy,

yes, a fatal "memory exhausted" error usually results in a blank page. You will find the error message in your PHP error log file. This particular error is not displayed in the browser, even if the php.ini file is set to print error messages in the browser window - probably because PHP is in fact really so exhausted that there are not even enough memory resources available to print the error. As you said increasing the memory limit should fix the problem.

Cheers!
Anatol

Go to Top