Why is "Request used more than 300 MB of RAM: 720 MB" fatal?

The Basics

  • Nextcloud Server version:
    • Nextcloud Hub 10 (31.0.5)
  • Operating system and version:
    • Linux Mint 22.1 (~ Ubuntu 24.04)
  • Web server and version:
    • nginx 1.24.0
  • Reverse proxy and version:
    • none
  • PHP version:
    • 8.3.6
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • May 28, 2025, 11:23:28 PM = ~ 5 hours after upgrading my server (was on an end-of-live version before, can’t remember which - the upgrader needed ~3 steps to reach the up-to-date version)
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • archive originally, but have upgraded many times using the web-based upgrader linked from admin panel
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • no

Summary of the issue you are facing:

Log entries with level “fatal” sound scary, and I don’t understand why this one should be fatal. The server my Nextcloud instance is running on now has 16GB of RAM, so 300MB should not be a problem. I did not notice any user-facing feature not working - looking at the log entry in between the two fatal ones it looks like it was caused by a cron job running and not a client of mine.

Nextcloud Log entries

{"reqId":"py75aKcjdOY48CWzk8V6","level":4,"time":"2025-05-28T21:26:49+00:00","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":"Request used more than 300 MB of RAM: 720 MB","userAgent":"--","version":"31.0.5.1","data":{"app":"core"},"id":"683806141d594"}
{"reqId":"py75aKcjdOY48CWzk8V6","level":2,"time":"2025-05-28T21:26:49+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Cron job used more than 300 MB of ram after executing job OCA\\Files\\BackgroundJob\\ScanFiles (id: 10, arguments: null): 720 MB (before: 32.9 MB)","userAgent":"--","version":"31.0.5.1","data":{"app":"cron"},"id":"683806141d59c"}
{"reqId":"4g9KlTGNJP0fKjejxVSG","level":4,"time":"2025-05-28T21:23:28+00:00","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":"Request used more than 300 MB of RAM: 728.4 MB","userAgent":"--","version":"31.0.5.1","data":{"app":"core"},"id":"683806141d5a1"}

Can’t find any web server log entries during that time period, probably because it was caused by the cron job that doesn’t go through the webserver.

Configuration

Nextcloud

{
    "system": {
        "debug": false,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.16.5",
            "***REMOVED SENSITIVE VALUES MANUALLY***"
        ],
        "maintenance_window_start": 1,
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "https:\/\/my-domain\/nextcloud",
        "overwriteprotocol": "https",
        "dbtype": "mysql",
        "version": "31.0.5.1",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_smtpauthtype": "LOGIN",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "theme": "",
        "default_phone_region": "AT",
        "loglevel": 2,
        "updater.release.channel": "stable",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 0
        },
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "smtp",
        "mail_smtpauth": 1,
        "mail_smtpport": "465",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpdebug": true,
        "twofactor_enforced": "false",
        "twofactor_enforced_groups": [],
        "twofactor_enforced_excluded_groups": [],
        "mail_smtpsecure": "ssl",
        "app_install_overwrite": [
            "spreed"
        ],
        "mysql.utf8mb4": true,
        "filelocking.enabled": true
    }
}

Apps

Enabled:
  - activity: 4.0.0
  - admin_audit: 1.21.0
  - app_api: 5.0.2
  - calendar: 5.3.0
  - circles: 31.0.0
  - cloud_federation_api: 1.14.0
  - comments: 1.21.0
  - contacts: 7.1.1
  - contactsinteraction: 1.12.0
  - dashboard: 7.11.0
  - dav: 1.33.0
  - deck: 1.15.1
  - federatedfilesharing: 1.21.0
  - files: 2.3.1
  - files_downloadlimit: 4.0.0
  - files_pdfviewer: 4.0.0
  - files_reminders: 1.4.0
  - files_sharing: 1.23.1
  - files_trashbin: 1.21.0
  - files_versions: 1.24.0
  - firstrunwizard: 4.0.0
  - logreader: 4.0.0
  - lookup_server_connector: 1.19.0
  - mail: 5.1.1
  - nextcloud_announcements: 3.0.0
  - notes: 4.12.1
  - notifications: 4.0.0
  - oauth2: 1.19.1
  - photos: 4.0.0-dev.1
  - profile: 1.0.0
  - provisioning_api: 1.21.0
  - recommendations: 4.0.0
  - related_resources: 2.0.0
  - serverinfo: 3.0.0
  - settings: 1.14.0
  - sharebymail: 1.21.0
  - systemtags: 1.21.1
  - tasks: 0.16.1
  - text: 5.0.0
  - theming: 2.6.1
  - twofactor_backupcodes: 1.20.0
  - updatenotification: 1.21.0
  - user_status: 1.11.0
  - viewer: 4.0.0
  - weather_status: 1.11.0
  - webhook_listeners: 1.2.0
  - workflowengine: 2.13.0
Disabled:
  - bruteforcesettings: 4.0.0 (installed 1.0.3)
  - encryption: 2.19.0
  - federation: 1.21.0 (installed 1.3.0)
  - files_external: 1.23.0
  - files_rightclick: 0.15.1 (installed 1.6.0)
  - password_policy: 3.0.0 (installed 1.13.0)
  - privacy: 3.0.0 (installed 1.0.0)
  - support: 3.0.0 (installed 1.6.0)
  - survey_client: 3.0.0 (installed 1.1.0)
  - suspicious_login: 9.0.1
  - twofactor_nextcloud_notification: 5.0.0
  - twofactor_totp: 13.0.0-dev.0
  - user_ldap: 1.22.0

See Bug report on Github:

1 Like

The RAM for PHP-FPM is important, not the RAM for your server.

Please check php.ini of the relevant PHP-FPM service how much memory is allowed, for example in /etc/php/8.3/fpm/php.ini. Check memory_limit there. It should be something like this for 2 GB per process:

memory_limit = 2048M

Also check this for PHP-CLI (/etc/php/8.3/cli/php.ini).

1 Like

fpm was set to 512M, cli was set to -1 (which I guess means unlimited?). I’ve changed both to 2048M.

The 300mb limit must come from somewhere in nextcloud itself if I’ve correctly understood what I’ve read about this error message so far. (If php where to enforce such a limit, there where no chance of nextcloud using 720mb as reported by the fatal error message..)

Message has nothing to do with PHP settings. It comes from base.php, where it register_shutdown_function.

It basically logs this whenever “peak memory usage” exceeds 300MB (Warning), 400MB (Error), or 500MB (Fatal).

Not a Nextcloud expert myself, but it does seem like a false positive, as AFAICT it’s not related to a script error at all.