When trying to generate image previews using the occ preview:generate-all command, The following error is thrown:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) in /var/www/html/lib/private/legacy/image.php on line 477
According to phpinfo() the memory_limit is set to 128M. Can this be increased? I could not find a php.ini file to change this variable. Changing it to 2048M in .htacces and .user.ini did not resolve the issue.
I am running the standard docker image (not using docker-compose).
I've checked all config files for a reference to the 128M memory, but I cannot locate it.
These are the config files according to php -i
Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => (none)
Scan this dir for additional .ini files => /usr/local/etc/php/conf.d
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini,
/usr/local/etc/php/conf.d/docker-php-ext-exif.ini,
/usr/local/etc/php/conf.d/docker-php-ext-gd.ini,
/usr/local/etc/php/conf.d/docker-php-ext-intl.ini,
/usr/local/etc/php/conf.d/docker-php-ext-ldap.ini,
/usr/local/etc/php/conf.d/docker-php-ext-mcrypt.ini,
/usr/local/etc/php/conf.d/docker-php-ext-memcached.ini,
/usr/local/etc/php/conf.d/docker-php-ext-mysqli.ini,
/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pgsql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-redis.ini,
/usr/local/etc/php/conf.d/docker-php-ext-zip.ini,
/usr/local/etc/php/conf.d/opcache-recommended.ini
However the only references to 'memory' are set in opcache-recommended and .user.ini, and I've set them both to 512M without avail.
/usr/local/etc/php/php.ini does not exist, is that a problem?
I managed to fix the memory limit by manually creating /usr/local/etc/php/php.ini in the docker container, changing it to the correct user/group, and adding this single line:
memory_limit=512M
I was then able to pre-generate my gallery previews, which was running out of memory with 128M limit.
It seems that the memory directives in _opcache-recommended.ini_ and _.user.ini_ have an effect on the _local value_ according to phpinfo, but does not edit the _master value_. Is this a bug?
Duplicate of #182
I fixed this problem by
/usr/local/etc/php/php.ini file inside containermemory_limit=1024M in new file ;) php -r "echo ini_get('memory_limit').PHP_EOL;"Another method, that I found a bit more reliable (because it takes precedent over other php.ini settings,) is to create a custom config file.
Create a file on your host machine. In my case, I was updating the max upload size: /Users/[username]/docker/php/uploads.ini
Add custom settings to your new file:
max_execution_time=600
memory_limit=-1
upload_max_filesize = 64M
... any other settings
Inside your docker-compose.yml file, add this to the volumes section of the desired container: /Users/[username]/docker/php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
Restart your docker container and it should show the new settings.
Most helpful comment
I fixed this problem by
/usr/local/etc/php/php.inifile inside containermemory_limit=1024Min new file ;)php -r "echo ini_get('memory_limit').PHP_EOL;"