nextcloud / nextcloud/server

[Bug]: [cron] Warning: Memory leak detected after executing job OCA\Files_Trashbin\BackgroundJob\ExpireTrash (id: 2540, arguments: null). Memory usage grew by 85 MB.

Open
#62,417 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 34-feedback bug feature: trashbin performance 🚀
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

Our up to date nextcloud server with ~2100 Users (which 500 are deactivated) and ~1.3TB of Data across them reports a memory leak during trashbin expiration cronjobs.

Steps to reproduce
  1. Have a large (single-Node) and carried through all sorts of versions of an installation of Nextcloud
  2. Have Users do things or not. Seems to not care that much as it also happens during the middle of the night (when nobody access it apart from a few outliers and iphone clients that asks for syncs.
  3. Cronjob
  4. Profit
Expected behavior

Memory Leak would not get reported (tbf. it's more for you to maybe identify the problem and i respect that)

Nextcloud Server version

34

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.4

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 31 to 32)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***",
            "***REMOVED SENSITIVE VALUE***"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "34.0.2.1",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "DE",
        "installed": true,
        "mail_smtpmode": "sendmail",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "asset-pipeline.enabled": true,
        "force_language": "de_DE",
        "preview_max_x": 750,
        "preview_max_y": 750,
        "maintenance_window_start": 1,
        "preview_libreoffice_path": "\/usr\/bin\/libreoffice",
        "preview_office_cl_parameters": "",
        "preview_max_scale_factor": 1,
        "theme": "",
        "maintenance": false,
        "loglevel": 2,
        "forcessl": true,
        "trashbin_retention_obligation": "auto, 61",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "integrity.check.disabled": false,
        "auth.bruteforce.protection.enabled": false,
        "skeletondirectory": "\/data\/skeleton",
        "updater.release.channel": "stable",
        "overwrite.cli.url": "https:\/\/***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "smtp",
        "mail_smtpport": "25",
        "mysql.utf8mb4": true,
        "filelocking.enabled": "true",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "dbindex": 1
        },
        "serverid": 1,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "forwarded_for_headers": [
            "HTTP_X_FORWARDED_FOR"
        ]
    }
}
List of activated Apps
Enabled:
  - activity: 7.0.0
  - announcementcenter: 7.4.1
  - appstore: 1.0.0
  - bruteforcesettings: 7.0.0
  - calendar: 6.5.1
  - circles: 34.0.0
  - cloud_federation_api: 1.18.0
  - comments: 1.24.0
  - contacts: 8.7.4
  - contactsinteraction: 1.15.0
  - dav: 1.39.0
  - deck: 1.18.2
  - federatedfilesharing: 1.24.0
  - federation: 1.24.0
  - files: 2.6.0
  - files_downloadlimit: 5.2.0
  - files_lock: 34.0.1
  - files_reminders: 1.7.0
  - files_sharing: 1.26.0
  - files_trashbin: 1.24.0
  - files_versions: 1.27.0
  - logreader: 7.0.0
  - lookup_server_connector: 1.22.0
  - nextcloud_announcements: 6.0.0
  - notifications: 7.0.0-dev.1
  - oauth2: 1.22.0
  - office: 1.0.0
  - ownershiptransfer: 1.5.0
  - password_policy: 6.0.0-dev.0
  - photos: 7.0.0
  - privacy: 6.0.0-dev.1
  - profile: 1.3.0
  - provisioning_api: 1.24.0
  - recommendations: 7.0.0
  - related_resources: 5.0.0-dev.0
  - serverinfo: 6.0.0
  - settings: 1.17.0
  - sharebymail: 1.24.0
  - survey_client: 6.0.0-dev.0
  - systemtags: 1.24.0
  - text: 8.0.0
  - theming: 2.9.0
  - twofactor_backupcodes: 1.23.0
  - twofactor_totp: 16.0.0
  - updatenotification: 1.24.0
  - user_retention: 1.17.0
  - viewer: 7.0.0-dev.0
  - weather_status: 1.14.0
  - webhook_listeners: 1.6.0
  - workflowengine: 2.16.0
Disabled:
  - admin_audit: 1.24.0
  - app_api: 34.0.0 (installed 32.0.0)
  - dashboard: 7.14.0 (installed 7.0.0)
  - encryption: 2.22.0
  - files_external: 1.26.0 (installed 1.21.0)
  - files_pdfviewer: 7.0.0-dev.0 (installed 1.1.1)
  - firstrunwizard: 7.0.0-dev.0 (installed 2.2.1)
  - richdocuments: 10.2.0 (installed 10.2.0)
  - richdocumentscode: 26.4.104 (installed 26.4.104)
  - spreed: 23.0.7 (installed 23.0.7)
  - support: 6.0.0 (installed 1.5.0)
  - suspicious_login: 12.0.0-dev.0
  - testing: 1.23.0
  - twofactor_nextcloud_notification: 8.0.0
  - user_ldap: 1.25.0
  - user_status: 1.14.0 (installed 1.0.1)
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
{"reqId":"v7Dfk1KJTEXbTHS93ZjL","level":2,"time":"2026-07-22T15:10:33+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","scriptName":"/data/var/www/kacloud/cron.php","message":"Memory leak detected after executing job OCA\\Files_Trashbin\\BackgroundJob\\ExpireTrash (id: 2540, arguments: null). Memory usage grew by 85 MB.","userAgent":"--","version":"34.0.1.2","occ_command":["/data/var/www/kacloud/cron.php"],"data":{"app":"cron"},"id":"6a60e2f9ce696"}
{"reqId":"LB3D8k16jinjY9sRkKAS","level":2,"time":"2026-07-24T08:00:28+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","scriptName":"/data/var/www/kacloud/cron.php","message":"Memory leak detected after executing job OCA\\Files_Trashbin\\BackgroundJob\\ExpireTrash (id: 2540, arguments: null). Memory usage grew by 64.4 MB.","userAgent":"--","version":"34.0.2.1","occ_command":["/data/var/www/kacloud/cron.php"],"data":{"app":"cron"},"id":"6a631d586b236"}
Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at cron.php and the OCA\Files_Trashbin\BackgroundJob\ExpireTrash job named in the warning. Reproduce the cron run while monitoring memory, then inspect the trash expiration path to isolate what remains allocated. Done means the job no longer produces the reported memory-growth warning under comparable conditions, with regression coverage if an existing test entry point is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.