syncthing-gtk icon indicating copy to clipboard operation
syncthing-gtk copied to clipboard

Memory leak

Open joaofl opened this issue 6 years ago • 17 comments

I've noticed that, when I start syncthing-gtk it consumes around 40mb of RAM, but after 5 days, it is already at 1gb. See the figure attached: selection_002

I'm using Linux Mint 18.3, based Ubuntu 16.04. If I can help on debugging it, please let me know how.

joaofl avatar May 22 '18 15:05 joaofl

Weird, Syncthing-GTK doesn't really do anything leak-prone. Is there any action (like opening some dialog) that shows sudden increase of usage, or it just increases constantly?

kozec avatar May 22 '18 20:05 kozec

I did not observe anything like an abrupt increase in memory usage. I simply left it running these days, I kept updating files on a different machine. When I came back to this one, there was many notifications of update (from the OS notification center). Nothing more suspicious.

joaofl avatar May 23 '18 12:05 joaofl

I confirm it is happening. Opened it 2 days ago. It started using 40MB, later that days it was on 80MB, today it reached 500MB.

selection_003

The only recurring dialogs are those telling me the files were updated. Which by the way also present a bug on showing the links to the files. See below: selection_004

joaofl avatar May 25 '18 11:05 joaofl

Which by the way also present a bug on showing the links to the files. See below:

That's probably bug in whatever environment are you using, ST-GTK just sends text. In fact, it's probably not even a bug, there is no rule that it should parse links in 1st place. Is that Mate or Cinnamon? I can add code to disable links on it.

Anyway, I've basically left ST-GTK running for ~week and it takes 80MB, what's roundly same as fresh instance. I'll get Mint 18.3 into VM and check if I can find anything useful there later.

kozec avatar Jun 01 '18 15:06 kozec

I'm using Cinnamon 18.3

joaofl avatar Jun 01 '18 16:06 joaofl

It seems there is (another) memory leak in syncthing-gtk's Nemo integration, as you can see from the attached screenshot (no. 1, note: These screenshots were cropped and merged (badly), because I took them in a very screen-space occupying way. note 2: I took these three days ago). Both applications started at around 40 MB of memory used (not screenshotted unfortunately), but (especially for nemo-desktop) it quickly climbed. I have noticed this behaviour on two computers so far, both running Linux Mint 18.3 Cinnamon Edition. syncthing-gtk_nemo-memleak_merged Out of a fluke, I disabled syncthing-gtk's Nemo integration, restarted Nemo and lo and behold, no more rapidly increasing memory usage for nemo-desktop.

I have just now logged back in into that machine (on which I disabled the nemo-integration) and syncthing-gtk is currently occupying 1.2 GB of memory, so this does not seem to be the root cause of the memory leak reported in this issue. As you can see from the screenshot, the computer has been running for 4.5 days now. syncthing-gtk_memleak

Sorry for possibly piggy-back riding on this issue, even though this might have warranted a completely new issue on the tracker. Please tell me if you want me to open another issue for the Nemo integration thing.

niemalsnever avatar Jun 22 '18 23:06 niemalsnever

I confirm that I also have this issue.

Nemo and cinnamon integration was enabled. I now disabled both of them and will report whether that changes anything.

wiwie avatar Nov 05 '18 07:11 wiwie

This is not specific to Cinnamon. I am experiencing on XFCE 4.12 under Debian 9. Confirmed on multiple boxes. On one that I have just checked, it's consuming ~500MiB.

Edit: I've just checked an Ubuntu 18.04 box (still XFCE 4.12) and the usage starts low as expected (about 70MiB) and appears to be climbing at approximately 15MiB / hour.

As a short term fix, use a small bash script to start it, and watch until it's killed, then add a cron job at 5am to kill it.

Here's some instructions for those who don't know how to do this. This is only really suggested if you don't use Syncthing-gtk to manage starting syncthing, as it basically kills it in a dirty way. If you just use it for a quick overview and the spinning icon as I do, and you have Syncthing installed and started via systemctl as I do then this should be fine. You may want to check the UI setting to minimize to tray at start to avoid seeing syncthing-gtk at the forefront each morning.

Open terminal and create a file for our script:

nano start_st-gtk.sh

Add this:

#!/bin/bash
until syncthing-gtk; do
    echo "Syncthing-GTK stopped. Code: $?.  Restarting.." >&2
    sleep 5
done

When done press Ctrl-X, Y, [enter] to save and exit.

Make the file executable:

sudo chmod u+x start_st-gtk.sh

Edit your syncthing-gtk startup entries and dock icons etc to point to that script.

Now let's use cron to kill syncthing-gtk at an inoffensive time:

crontab -e

You'll probably want to choose Nano if asked about a text editor.

Add this to end:

0 5 * * * killall syncthing-gtk

When done press Ctrl-X, Y, [enter] to save the crontab.

This cron entry will kill syncthing-gtk at 5am (not a clean exit, needed for the above script).

What the script does is start syncthing-gtk and watch for it to exit with an error using until. This is important, because if we quit it ourselves (exit code 0), we don't want it to restart. If syncthing-gtk exits, with any code other than 0, it will be restarted after 5 seconds. The cron job we added kills syncthing-gtk at 5am causing an unclean exit, and then it is restarted.

Edit: Changed method to quit/restart st-gtk. Cleaner, more acceptable. Other stuff. Many typos :)

ellnic avatar Feb 24 '19 11:02 ellnic

Issue persists in Linux Mint 20.

akwala avatar Dec 22 '20 19:12 akwala

2.5 GB accumulated. This one is really bad.

admirabilis avatar Jul 29 '21 15:07 admirabilis

Ubuntu MATE 22.04 - PPA package Screenshot at 2023-02-25 10-16-49

UnderEu avatar Feb 25 '23 13:02 UnderEu

The memory leak is huge and just in a matter of a few minutes (take a look at the screenshots). After syncthing-gtk running is for a whole work day, the memory used goes to 9 Gb in my case. I noticed it leaks faster after displaying the UI, but even without displaying it, the memory leak is present. This is under Ubuntu 22.04.2

Screenshot from 2023-03-13 14-58-11 Screenshot from 2023-03-13 15-04-15

MarceloRuiz avatar Mar 13 '23 19:03 MarceloRuiz

@MarceloRuiz @UnderEu

This project is dead.

I was hoping for the longest time that the leak would be fixed but I have long since come to the conclusion that it won’t be and have abandoned it.

238 days since last commit, memory leak non fixed for almost 5 years.

Dead. A real shame. 😞

ellnic avatar Mar 13 '23 22:03 ellnic

I have same problem Memory leak

al-sa avatar Jul 24 '23 12:07 al-sa

I've just had this happen to me:

[Fr Okt 20 19:23:07 2023] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=systemd-journald.service,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/[email protected]/app.slice/app-Syncthing\[email protected],task=syncthing-gtk,pid=5818,uid=1000
[Fr Okt 20 19:23:07 2023] Out of memory: Killed process 5818 (syncthing-gtk) total-vm:20262076kB, anon-rss:18113340kB, file-rss:632kB, shmem-rss:0kB, UID:1000 pgtables:37760kB oom_score_adj:200

Distro: Ubuntu 23.04 Kernel: 6.2.0-34-generic Uptime: Up 1 day, 23:17 Version: syncthing-gtk 0.9.4.4+ds+git20221205+12a9702d29ab-1 System: 32GB RAM

mdPlusPlus avatar Oct 20 '23 17:10 mdPlusPlus

I've just had this happen to me

You and everyone else for the last 5 years ;-) if you'd have read the above comments you'd see that this project has been abandoned for many years.

Either use the hack (on second thoughts I actually hate that term in this context - dirty workaround is better) I suggested above to quit and restart the app, or use: https://github.com/Martchus/syncthingtray which seems to be the preferred tray app now.

ellnic avatar Nov 24 '23 21:11 ellnic

I have same problem

Memory leak

You guys crack me up. Have you read anything above your own comment? 😆

ellnic avatar Nov 24 '23 21:11 ellnic