Server: Nextcloud 16 - Migration from v15 - Allowed memory size of ... bytes exhausted

Created on 3 May 2019  Â·  22Comments  Â·  Source: nextcloud/server

Not knowing why, The migration through the 'beta' channel from v15 to v16 on yesterday failed. I had to finish it using command line.
Now Nextcloud left maintenance mode, but v16 is showing a Blank page: PHP Fatal error: Allowed memory size of ... bytes exhausted.

sudo -u www-data php ./occ status

  • installed: true
  • version: 16.0.0.9
  • versionstring: 16.0.0
  • edition:

Nextcloud - Nextcloud.log
{"reqId":"DxswUKaM6eSRyTPihpd5","level":3,"time":"2019-05-03T16:51:48+00:00","remoteAddr":"...","user":"...","app":"PHP","method":"GET","url":"\/ocs\/v2.php\/core\/navigation\/apps?absolute=true&format=json","message":"Allowed memory size of 2097152 bytes exhausted (tried to allocate 65536 bytes) at \/var\/www\/html\/...\/...\/lib\/composer\/composer\/ClassLoader.php#444","userAgent":"Mozilla\/5.0 (Macintosh) mirall\/2.5.1final (build 20181204) (Nextcloud)","version":"16.0.0.9"}

Apache2 - Error.log
[Fri May 03 18:50:48.175555 2019] [proxy_fcgi:error] [pid 16697:tid 140269823399680] [client ...:59282] AH01071: Got error 'PHP message: PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 65536 bytes) in /var/www/html/.../.../lib/composer/composer/ClassLoader.php on line 444PHP message: PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 65536 bytes) in Unknown on line 0'

Most helpful comment

Found the problem on my case !!
On your config php.ini (or in a custom file), the instruction memory_limit don't support GB value.
You need to specify the value in Mega : M
It's not linked to the version, both 7.2 and 7.3 work.

I don't know why it's was working before v16.

Az

All 22 comments

Exact the same problem here!

  • installed: true
  • version: 16.0.0.9
  • versionstring: 16.0.0

    • edition:

Error-Log: nextcloud php7:error client PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate (...)).

Downgraded from PHP 7.3 to PHP 7.2 and everything seems to work again. Under NC 15, PHP 7.3 worked like a charm.

You should check your php.ini for the entry _memory_limit =_ and increase it to at least 256 MB. Seems to be configured to roughly 2 MB currently.

Thanks @Derridaralalala, PHP is so boring seriously... I don't even want to bother downgrading... I will just wait for an update. I guess it is the reason why it is still not in the "stable" channel.

Thanks @wiswedel, you are right, i don't understand why the message show this particular size. It is set to 512 MB, and it is confirmed by phpinfo().

Well, with Derridaralalala's help, I might say that one of the 3rd party modules is still not compatible with PHP 7.3. I'll just wait...
For beginners, as wiswedel says, never set memory_limit to "-1" to unlimited size, otherwise min. 256MB for a Nextcloud instance.

Regards,

You should check your php.ini for the entry _memory_limit =_ and increase it to at least 256 MB. Seems to be configured to roughly 2 MB currently.

That did not helped in the particular case, even with 512MB set in php.ini in all directories (apache2, cli ...).

Maybe there's an override php_value memory_limit in the .htaccess?

Thanks @Derridaralalala, PHP is so boring seriously... I don't even want to bother downgrading... I will just wait for an update. I guess it is the reason why it is still not in the "stable" channel.

A possibility. At least sync clients now work again and no blank page anymore. Downgrading is pretty simple (if already used 7.2 b4). E.g.
_sudo a2dismod php7.3
sudo a2enmod php7.2_
check syntax and restart apache: _service apache2 restart_
Of course, this is only for apache.

Some problems still persists though:
Testing with sudo _-u www-data php /var/www/nextcloud/occ upgrade_ i get
_HP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 4096 bytes) in /var/www/nextcloud/3rdparty/composer/autoload_static.php on line xxx)_
Cronjob (cron) also stopped working -- but maybe both unrelated or maybe because _php -v_ is still on PHP 7.3.x.

@ShouldIPressTheButton can you reopen?

Maybe there's an override php_value memory_limit in the .htaccess?

@wiswedel "It did not helped" in the sense that the main problem (blank page, no sync cli working) still was around. PHP downgrading from 7.3 to 7.2 solved this particular problem, but not the memory size issue. Monitoring in NC webcli shows correctly: _PHP / Version: 7.2.18 / Memory Limit: 512 MB_ and no warning on the front page anymore.

Yeah... you're right :'(
For my part, Errors are always related to loading dependency files.

For the moment, it is mostly while trying to load L10N language files:
"PHP","method":"PROPFIND","url":"\/remote.php\/webdav\/","message":"Allowed memory size of 2097152 bytes exhausted (tried to allocate 4096 bytes) at \/var\/www\/html\/...\/...\/lib\/private\/L10N\/L10N.php#235","userAgent":"Mozilla\/5.0 (Macintosh) mirall\/2.5.1final (build 20181204) (Nextcloud)","version":"16.0.0.9"}

I feel it is very related to Symphony because of : "PHP","method":"GET","url":"\/ocs\/v2.php\/core\/navigation\/apps?absolute=true&format=json","message":"Allowed memory size of 2097152 bytes exhausted (tried to allocate 65536 bytes) at \/var\/www\/html\/...\/...\/lib\/composer\/composer\/ClassLoader.php#444","userAgent":"Mozilla\/5.0 (Macintosh) mirall\/2.5.1final (build 20181204) (Nextcloud)","version":"16.0.0.9"}

Found the problem on my case !!
On your config php.ini (or in a custom file), the instruction memory_limit don't support GB value.
You need to specify the value in Mega : M
It's not linked to the version, both 7.2 and 7.3 work.

I don't know why it's was working before v16.

Az

Thanks Az for your reply !

I deleted my old version, so I won't be able to confirm from it,
but I have reinstalled a fresh v16 and... there is no problem at all ^^.

PHP is just a joke... I will wait for Cozy Cloud to enable encryption, and I will be one step futher on the road to never use PHP again.

Okey so Nextcloud 16 doesn't support PHP 7.3 and I need to downgrade PHP to make the CLI work. Did I understand that right?

Hello,

Something went wrong on your side ?

For me, it was the migration from v15 to v16 which failed. I can't say why, but it might have been php 7.3 related.
Otherwise, I've build an other one from the ground, over php 7.3, and it works well.

I found the solution for my problem posted by @rahlquist here:
https://help.nextcloud.com/t/allowed-memory-size-of-xxx-bytes-exhausted/39371
I needed to set the memory_limit to -1 in cli/php.ini

Again, if you are simply installing for the first time, it should go well. No worries to have.

I 100% don't recommand that lame solution… its unset the boundaries of you php memory, if something goes wrong, it's your whole server that blows… I really hate that some people can suggest that kind of solution. I rather have no solution than that kind of crap.

if you have difficulties, try @azlux, above… as for me, as I said, reinstalling it worked well.

Well, I'm not installing for the first time, and I'm not willing to redo my ages old back then Owncloud now Nextcloud installation from scratch.

And I don't consider a missing memory limit in php CLI version problematic, since nobody has CLI access to that system other than me.

I did some profiling and my maximum apache child process got up to 489MB (mod_php for now) with a file sync. So, 512M _might_ have been a setting I could use.

But I don't have any information to be sure that other Nextcloud processes won't use more than that, or even file sync under other conditions than I tested. I have Nextcloud on its own vm so the worst that can happen is that occasionally the vm will go OOM . What's a much worse scenario is that everybody's sync fails. So, I reluctantly went withmemory_limit = -1 (in my /etc/php/7.3/apache2/conf.d/30-nextcloud.ini) since I don't have better data and I watch total system memory with munin and nagios anyway (I can allocate more to the vm if needed).

If there's a unit test that puts Nextcloud under maximum memory pressure, to establish an ideal memory limit value with no chance of overrun, I'd love to know about it. I suppose this would need to be reestablished for every release. Upgrading and then watching for my users' syncs to break or not isn't an approach that delivers a good user experience.

We show a warning if the memory limit is below 512mb. A memory_limit of 512mb should be fine. If you have enough memory use 1024mb.

Same problem here. I had to go back to php7.1 memory limit -1.
With php7.2 or php7.3 white page and memory error in logfile. Memory limit on 512mb is not sufficient enough.
I am running on Nextcloud 17.0.0

Same happened on NC 16.0.5.
PHP 7.2.24-0ubuntu0.18.04.1

Memory limit 1000MB didn't help but -1 did, which is weird.

"MB" is invalid notation.
Only K, M or G are allowed.
See https://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes and https://www.php.net/manual/en/ini.core.php#ini.memory-limit for more information.

Oh god... thank you for pointing that out. It works now.

Was this page helpful?
0 / 5 - 0 ratings