Nextcloud out-of-memory PHP error

0 minute read

I got this error when upgrading to nextcloud 21:

PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) [...]

Turns out this is the way to solve it: Prefix PHP_MEMORY_LIMIT=512M to the commands. In combination with docker it looks like this:

/usr/bin/docker exec -u 33 srv_nc_1 /bin/bash -c 'PHP_MEMORY_LIMIT=512M php occ db:add-missing-indices'

... OR USING -e ...

/usr/bin/docker exec -u 33 -e PHP_MEMORY_LIMIT=512M srv_nc_1 /bin/bash -c 'php occ db:add-missing-indices'


~$ docker exec -tiu 33 srv_nc_1 /bin/bash
~# PHP_MEMORY_LIMIT=512M php occ db:add-missing-indices