Changes to memory_limit doesn't take effect

Nextcloud version: Nextcloud 13.0.8
Operating system and version: DISTRIB_DESCRIPTION=“Ubuntu 18.04.1 LTS”
Apache or nginx version: can’t get
PHP version: 7.2

The issue you are facing:
I’ve tried to search for topics related to NC with snap installation and changing php memory_limit to 256M/512M but keep getting following error message when browsing to folders that tried to generate the image preview:

[23-Dec-2018 15:33:10 UTC] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) in /snap/nextcloud/10317/htdocs/lib/private/legacy/image.php on line 892

I’ve tried to change the following files but with no success.

  1. /etc/php/7.2/cli/php.ini
  2. php/7.2/phpdbg/php.ini
  3. /var/snap/nextcloud/10317/nextcloud/config/config.php
  4. /snap/nextcloud/10317/htdocs/config/.htaccess

Is this the first time you’ve seen this error? (Y/N):N

Steps to replicate it:

  1. login to NC
  2. click ‘gallery’
  3. click on an folder with pictures

The output of your Nextcloud log in Admin > Logging:
[23-Dec-2018 15:33:10 UTC] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) in /snap/nextcloud/10317/htdocs/lib/private/legacy/image.php on line 892

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php $CONFIG = array ( 'apps_paths' => array ( 0 => array ( 'path' => '/snap/nextcloud/current/htdocs/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => '/var/snap/nextcloud/current/nextcloud/extra-apps', 'url' => '/extra-apps', 'writable' => true, ), ), 'supportedDatabases' => array ( 0 => 'mysql', ), 'memcache.locking' => '\\OC\\Memcache\\Redis', 'memcache.local' => '\\OC\\Memcache\\Redis', 'redis' => array ( 'host' => '/tmp/sockets/redis.sock', 'port' => 0, ), 'instanceid' => 'ociinr57wvw0', 'passwordsalt' => '', 'secret' => '', 'trusted_domains' => array ( 0 => '192.168.1.xx', 1 => 'xx.duckdns.org', ), 'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data', 'overwrite.cli.url' => 'http://192.168.1.66', 'dbtype' => 'mysql', 'version' => '13.0.8.2', 'dbname' => 'nextcloud', 'dbhost' => 'localhost:/tmp/sockets/mysql.sock', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'nextcloud', 'dbpassword' => '', 'installed' => true, 'memory_limit' => -1, ); The output of your Apache/nginx/system log in `/var/log/____`: root@odroid:/var/log# tail syslog Dec 23 15:15:13 odroid nextcloud.apache[4442]: Making sure nextcloud is fully upgraded... Dec 23 15:15:15 odroid nextcloud.apache[4442]: Nextcloud is already latest version Dec 23 15:15:15 odroid nextcloud.apache[4442]: All set! Running httpd... Dec 23 15:15:15 odroid nextcloud.apache[4442]: Certificates have been activated: using HTTPS only Dec 23 15:15:15 odroid nextcloud.apache[4442]: Certificates look to be in order: enabling HSTS Dec 23 15:15:15 odroid nextcloud.apache[4442]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message Dec 23 15:17:01 odroid CRON[5076]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Dec 23 15:39:01 odroid CRON[6601]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi) Dec 23 15:39:01 odroid systemd[1]: Starting Clean php session files... Dec 23 15:39:02 odroid systemd[1]: Started Clean php session files.

I’ve just found the solution to changing the snap memory_limit, refer to this document https://github.com/nextcloud/nextcloud-snap

If you’d like to set the memory limit to a higher value (say, 512M), run:

$ sudo snap set nextcloud php.memory-limit=512M