mail icon indicating copy to clipboard operation
mail copied to clipboard

`PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 11605029 bytes) in /var/www/html/nextcloud/apps/mail/lib/Db/MessageMapper.php on line 583`

Open hboetes opened this issue 11 months ago • 5 comments

Steps to reproduce

I regularly get emails like that from the cronjob: /usr/bin/php -f /var/www/html/nextcloud/cron.php. Please tell if you want me to run some debug commands to get more informative output.

Expected behavior

No memory overload. :-}

Actual behavior

Memory overload.

Mail app version

4.1.2

Nextcloud version

30.0.5

Mailserver or service

postfix

Operating system

Fedora

PHP engine version

PHP 8.3

Nextcloud memory caching

'memcache.local' => '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'memcache.distributed' => '\OC\Memcache\Redis',

Web server

Nginx

Database

PostgreSQL

Additional info

No response

hboetes avatar Feb 02 '25 17:02 hboetes

Hi @hboetes

Is there any indication to which background job is causing this? Is there more details in the nextcloud.log? Otherwise this error might be hard to track down.

SebastianKrupinski avatar Feb 02 '25 18:02 SebastianKrupinski

Would this help? I simply searched for MessageMapper in the log, and then grepped for the matching log entry strings. I'm not a noob, but I have no idea how to debug this problem. Please make some suggestions.

root@bran /var/log/nextcloud # grep 1FUn7BlKfr8bgkdCHu8u log
{"reqId":"1FUn7BlKfr8bgkdCHu8u","level":0,"time":"2025-02-02T11:20:00+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"CLI cron call has selected job OCA\\Notifications\\BackgroundJob\\GenerateUserSettings (id: 10, arguments: null)","userAgent":"--","version":"30.0.5.1","data":{"app":"cron"}}
{"reqId":"1FUn7BlKfr8bgkdCHu8u","level":3,"time":"2025-02-02T11:20:33+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"iconv(): Detected an illegal character in input string at /var/www/html/nextcloud/apps/mail/lib/IMAP/Charset/Converter.php#43","userAgent":"--","version":"30.0.5.1","data":{"app":"PHP"}}
{"reqId":"1FUn7BlKfr8bgkdCHu8u","level":3,"time":"2025-02-02T11:20:34+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"iconv(): Detected an illegal character in input string at /var/www/html/nextcloud/apps/mail/lib/IMAP/Charset/Converter.php#43","userAgent":"--","version":"30.0.5.1","data":{"app":"PHP"}}
{"reqId":"1FUn7BlKfr8bgkdCHu8u","level":3,"time":"2025-02-02T11:20:42+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"iconv(): Detected an illegal character in input string at /var/www/html/nextcloud/apps/mail/lib/IMAP/Charset/Converter.php#43","userAgent":"--","version":"30.0.5.1","data":{"app":"PHP"}}
{"reqId":"1FUn7BlKfr8bgkdCHu8u","level":3,"time":"2025-02-02T11:20:43+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"iconv(): Detected an illegal character in input string at /var/www/html/nextcloud/apps/mail/lib/IMAP/Charset/Converter.php#43","userAgent":"--","version":"30.0.5.1","data":{"app":"PHP"}}
{"reqId":"1FUn7BlKfr8bgkdCHu8u","level":3,"time":"2025-02-02T11:21:21+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"iconv(): Detected an illegal character in input string at /var/www/html/nextcloud/apps/mail/lib/IMAP/Charset/Converter.php#43","userAgent":"--","version":"30.0.5.1","data":{"app":"PHP"}}
{"reqId":"1FUn7BlKfr8bgkdCHu8u","level":3,"time":"2025-02-02T11:21:22+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"iconv(): Detected an illegal character in input string at /var/www/html/nextcloud/apps/mail/lib/IMAP/Charset/Converter.php#43","userAgent":"--","version":"30.0.5.1","data":{"app":"PHP"}}
{"reqId":"1FUn7BlKfr8bgkdCHu8u","level":3,"time":"2025-02-02T11:21:25+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"iconv(): Detected an illegal character in input string at /var/www/html/nextcloud/apps/mail/lib/IMAP/Charset/Converter.php#43","userAgent":"--","version":"30.0.5.1","data":{"app":"PHP"}}
{"reqId":"1FUn7BlKfr8bgkdCHu8u","level":3,"time":"2025-02-02T11:21:25+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"iconv(): Detected an illegal character in input string at /var/www/html/nextcloud/apps/mail/lib/IMAP/Charset/Converter.php#43","userAgent":"--","version":"30.0.5.1","data":{"app":"PHP"}}
{"reqId":"1FUn7BlKfr8bgkdCHu8u","level":3,"time":"2025-02-02T12:09:24+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Allowed memory size of 536870912 bytes exhausted (tried to allocate 11605029 bytes) at /var/www/html/nextcloud/apps/mail/lib/Db/MessageMapper.php#583","userAgent":"--","version":"30.0.5.1","data":{"app":"PHP"}}

hboetes avatar Feb 02 '25 19:02 hboetes

@SebastianKrupinski 🏓

ChristophWurst avatar Jun 03 '25 12:06 ChristophWurst

Hi @hboetes

I was hoping the log entry would more information but this will have to do.

Looks like its the PreviewEnhancer background job, its failing when trying to update the database. I am guessing that you have a large mailbox and the job is trying to process too many messages at once.

A quick work around would be to increase the memory limit for PHP, try 1024MB, or 2048MB, once the job runs a couple times you can decrease it to 512MB again. As those messages will not need to be processed again.

SebastianKrupinski avatar Jun 03 '25 17:06 SebastianKrupinski

I just reinstalled the mail application and increased the php-fpm memory limit to 8Gb and the error is gone. Feels like a workaround indeed. Why would scanning a bunch of emails in the background take up so much memory? The limit was 512Mb. My largest email is 16Mb.

hboetes avatar Jun 07 '25 17:06 hboetes