I have been getting the dreaded error below for quite a while.
Allowed memory size of 536870912 bytes exhausted (tried to allocate 347852816 bytes) at /var/www/nextcloud/apps/dav/lib/CardDAV/CardDavBackend.php#972
I have read many threads on potential solutions here, but have yet to make the slightest progress toward a solution. This is because I am a Linux idiot with zero expertise, yes, but it is also because there is (I guess?) no simple settings access through NC admin, nor no step-by-step guide for learners to how to edit config directly?
It seems strange that such a simple problemānamely, that more memory should be allocated to run NC correctly the next time it startsāhas no straightforward solution through the admin interface? Or am I missing something? Please help me write this n00b how-to!
Of course, the obvious problem here is that I am unqualified as a Linux user or a NC CLI user. This is my failing, but also seems quite a high barrier to non-nerd adoption.
Iām sure this is answered somewhere in the forumā¦ Howeverā¦
The āallowed-memoryā error is due to the default memory_limit variable that is set in php.ini at a value lower than 512M.
Youāll need to locate the appropriate php.ini configuration file that is being used by your web server. On a typical Linux box that file will be located somewhere in the /etc directory.
Hereās a one-line bash script to find all the php.ini files in your /etc directory. Caveat, YMMVā¦
files=$(find /etc -iname php.ini);for f in $files;do echo -e "\nphp.ini files found\n";echo "$f";grep -n memory_limit "$f";echo -e "\n"; done
The line number will appear next to the memory_limit value.
I can only speak to my experience, but Iāve never seen the one-line bash before, which is enough to make a little headway!
so two files found:
/etc/php/7.4/fpm/php.ini
409:memory_limit = 512M
/etc/php/7.4/cli/php.ini
409:memory_limit = -1
Iām not sure these are the right file because I donāt know how Iād know that it āmatches [my] web serverā, but the first number looks like a good candidate.
When I attempt to edit the first one, it tells me no permission. This I have read about in other places, usually someone saying to ābe rootā which Iām fairly certain I am, itās my NC admin user. So how to edit it is the next stuck.
Good question, I didnāt install from scratch (despite my madd skillz), used this, which doesnāt seem to mention nginx but the documentation isnāt that clear.
Regardless, I followed your instructions, used vim, had to up it three times, to 4GB??? before CardDav would work. Something is very funky there that it takes that much to serve 100 contacts or so plus a calendarā¦ but now, thanks to you @irongate, itās the kind of funky that works.
As penance, I will add a more thorough step-by-step this evening, and hopefully other equally lost souls will feel less so as I now do. Many thanks.
You may want to poke around in your nginx configuration if the NC instance is running on a platform that is also running other services or is Cloud based.
This serverfault thread may be a good place to start if youāre interested: