Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » memory limit exhausted with larger number of assets

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

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

Page: 1 2
Go to End
Author Topic: 75666 Views
  • Anatol
    Avatar
    126 Posts

    memory limit exhausted with larger number of assets Link to this post

    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

  • Sigurd
    Avatar
    Forum Moderator
    628 Posts

    Re: memory limit exhausted with larger number of assets Link to this post

    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?

  • Anatol
    Avatar
    126 Posts

    Re: memory limit exhausted with larger number of assets Link to this post

    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

  • Sigurd
    Avatar
    Forum Moderator
    628 Posts

    Re: memory limit exhausted with larger number of assets Link to this post

    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...

  • Anatol
    Avatar
    126 Posts

    Re: memory limit exhausted with larger number of assets Link to this post

    I added a ticket for this issue (#1929)

  • Sigurd
    Avatar
    Forum Moderator
    628 Posts
  • streetdaddy
    Avatar
    32 Posts

    Re: memory limit exhausted with larger number of assets Link to this post

    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');

  • Anatol
    Avatar
    126 Posts

    Re: memory limit exhausted with larger number of assets Link to this post

    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

    75666 Views
Page: 1 2
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.