Very high memory use when uploading photos only

I am having a strange problem when photos are uploaded either into talk or via automatic sync from a phone, but NOT when uploaded via a desktop sync client.

Currently the server is using about 450mb of memory, when a number of photos are put in a talk message or synced via the android client memory use spikes to 750mb for a period of hours and often results in a more short spike of memory use and an out of memory error with the kernel killing something important. This could happen on a batch of three photos, one is generally fine, more guarantees the server falling over. Other filetypes don’t seem to cause the problem, I’d need to do more testing of this though.

I can hammer desktop sync as hard as I like and there is no memory use spike at all, including uploading photos.

I’m on 29.0.2 but have had this problem going back to at least 28, maybe earlier. Debian 12, Apache. PHP 8.2.7.

Logfiles don’t report anything useful, everything works without error until we hit out of memory. This is a very small server with only two users.

I’m able to dig deeper than this but am not sure where to start, ideas are welcome.

The output of config.php

$CONFIG = array (
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' =>
  array (
    0 => '',
  'datadirectory' => '/var/www/html/nextcloud/data',
  'overwrite.cli.url' => '',
  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_admin',
  'dbpassword' => 'xxx',
  'logtimezone' => 'UTC',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  '' => 'stable',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'xxx',
  'mail_domain' => 'xxx',
  'mail_smtpauth' => 1,
  'mail_smtphost' => '',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'xxx',
  'mail_smtppassword' => 'xxx',
  'mysql.utf8mb4' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'overwriteprotocol' => 'https',
  'has_rebuilt_cache' => true,
  'default_phone_region' => '61',
  'app_install_overwrite' =>
  array (
    0 => 'maps',
    1 => 'news',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,

Do you have the preview generator installed? Just thinking if that triggers a preview image on certain upload methods…
Other file types don’t have this issue (e.g. when using talk)?

1 Like

This sounds like a very memory constrained environment. You may need to do various things to reduce the memory footprint:

  • lower preview generation concurrency: Configuration Parameters — Nextcloud latest Administration Manual latest documentation
  • preview memory parameters (see same section of the docs just linked)
  • Possibly FPM parameters (if using; that’s unclear)
  • Various app combinations could be problematic (maybe post the output of occ app:list
  • Make sure to have some swap configured. Even if it’s not ideal performance-wise, it’ll reduce chances of crashes/process kills at least