HelloWorld017 / atom-discord

Integrate with Discord and show Rich Presence information.
https://atom.io/packages/atom-discord
MIT License
105 stars 28 forks source link

RAM usage #32

Closed Ekidoxx closed 5 years ago

Ekidoxx commented 6 years ago

Description

Few seconds after launching the editor, this package makes Atom slowly increasing used RAM until it's consuming about 2,1 GB of memory - while in my case, normally, Atom uses around 700 MB. This makes whole editor either work amazingly slow, or even stuck at all...

Environment informations

Operating system: Windows 7 Home Premium 64-bit SP1 with 12,0GB RAM Atom version: 1.23.1 Package version: 1.4.0 Startup time addition: 355ms Reproduction rate: 100%

HelloWorld017 commented 6 years ago

Is anyone who has same error?

Ekidoxx commented 6 years ago

I recognized myself, that I didn't have this issue since the beginning of using Your package, so I thought I'd check if maybe Discord being launched has anything to do with the problem... And that's the test result:

What RAM usage
Discord ~245 MB
Atom ~885 MB*
Discord and Atom ~250 MB / ~890 MB
Atom with atom-discord package ~2.350 MB*
Discord and Atom with atom-discord package ~245 MB / ~900 MB

* Installed some more packages since creating this issue


However, after I launched both Discord and Atom with the package, and then closed Discord, RAM usage didn't increase back to the ~2.350 MB as I expected.

So, to me it seems like on launch the script(s) don't detect properly when to send rich presence information - and when incorrectly trying to send those into ether (as no Discord is running), something keeps looping something until being about to kill Atom. But that's just my thought, since I didn't understand even half the code :P

HelloWorld017 commented 6 years ago

For more information, please refer to #35

Hoi15A commented 6 years ago

I can reproduce the issue exactly like @Ekidoxx described, the only difference that I have noticed in my case is that in addition to using up way more ram is that it also makes my CPU usage go up drastically (~125% according to htop)


Here's some system information: OS: Arch Linux x86_64 (Kernel: 4.14.12-1-ARCH) RAM: 8GB Atom version: 1.23.2 Package version: 1.4.0

Ekidoxx commented 6 years ago

Hmm, I actually didn't even thought of checking CPU usage... Gonna test it once I have bit more free time

kaimoe commented 6 years ago

Same here, easily reproducible by starting Atom w/ the package without Discord running, letting it steadily accumulate memory usage while at ~40%+ CPU usage, and watching both immediately dip to normal by launching Discord. Closing Discord at that point does not cause the issue to reoccur.

Specs: OS: Windows 10 RAM: 8GB Atom version: 1.23.3 Package version: 1.4.0

TheOnlyArtz commented 6 years ago

Guys we need more information, can I ask you guys to test this issue while no tabs are being open except from the settings tab to enable/disable the package?

The reason for that is because Atom uses Electron and for every tab which you'll open another process will run in the background. Which, obviously will cost with RAM usage

HelloWorld017 commented 6 years ago

I suppose that IPC call when Discord is not running raised this error. So, I think checking is discord online using ps-node may help solving this error.

GitSquared commented 6 years ago

Started Atom with atom-discord. The package took 850ms to load, CPU usage stayed around 60 to 80% and RAM usage kept increasing until my system actually had to use the swap space. I could travel to the moon and back between when i opened a file and when Atom displayed it.

Clearly there is a memory leak somewhere.

Specs: OS: Arch Linux w/ Gnome RAM: 8GB + 4GB swap (Atom used a total of 7GB before i shut it down) Latest version of everything.

HelloWorld017 commented 6 years ago

When I tested two cases: with Discord and without Discord, I failed to reproduce this error. Maybe there is another factor to memory leak.

What RAM usage
Atom w/ atom-discord package w/o Discord ~280 MB
Atom w/ atom-discord package w/o Discord, 2 windows ~280 + 330 MB
Atom w/ atom-discord package, Discord ~290 MB

OS: Windows 10 RAM: 12GB Atom Version: 1.23.0-beta1 Package Version: 1.4.0

Ekidoxx commented 6 years ago

Any idea on what I/We could edit locally to check out if that would fix the issue?

Ekidoxx commented 6 years ago

@HelloWorld017 Are you sure that you have checked it with package version 1.4.0 and not with what's in master-branch?

Because once a weird thought came to me, I uninstalled the package and then manually installed it with content of this repo (as there were some commits that didn't get published under new release version) - And guess what, the bug has been fixed! :scream:

So, how about You'd soon release 1.4.1? :stuck_out_tongue: But before you do that, there's bug with latest issue and its merged pullrequest (https://github.com/HelloWorld017/atom-discord/issues/39 & https://github.com/HelloWorld017/atom-discord/pull/38)

HelloWorld017 commented 6 years ago

I uploaded 1.5.0 to the apm! 😄 Is anyone can confirm disappearance of this issue? 😆

Hoi15A commented 6 years ago

The issue still persists. Atom drains memory and uses the CPU like crazy until discord is started. htop showing massive cpu & ram usage

Closing discord again afterwards does not make the RAM be used up anymore.

The dev console in Atom does not show any errors while it is using up CPU and memory

HelloWorld017 commented 6 years ago

Would you tell me if the memory leak happens on the renderer process?

Also, would you get console output from the terminal?

HelloWorld017 commented 6 years ago

I think that dumping heap might help solving this issue.

Ekidoxx commented 6 years ago

Ok, with every next day it's getting more weird @HelloWorld017. After I updated the package through Atom, I again have this issue o.0'

HelloWorld017 commented 6 years ago

I hope this bug happens to me

HelloWorld017 commented 6 years ago

Would you get terminal output and check if this leak is happening on renderer process or on main process?

Ekidoxx commented 6 years ago

You mean by using one of these: output-panel / atom-terminal-panel?

HelloWorld017 commented 6 years ago

Umm... Actually I meant the cmd. If you open the cmd at the directory where atom executable is and execute atom by cmd, you can see logs of atom main process.

Ekidoxx commented 6 years ago

Seems that I do something wrong, because I can't manage to get any log output anywhere... When I do atom -l, atom -l ./atom.log, atom --log-file Atom.log, atom --log-file "Atom.log" no output is shown in command prompt, and no log file is created

GitSquared commented 6 years ago

@HelloWorld017 Seems like it's happening in the main process. I performed some tests using htop in a terminal:

Running Atom without atom-discord : normal

After enable & restart : rambug

When enabled, Atom's main process uses 60% of CPU (htop outputs the usage by core, so 150% CPU means a core and a half running at full speed) and eats about 30mb of RAM per second, definitely a leak.

I'm going to try snooping around your code ('cuz i really want the darn thing to work). Can you confirm that you can't reproduce the issue on your end?

HelloWorld017 commented 6 years ago

There is definitely a leak. But, I can't reproduce on my end and I'll upload screenshot and data next day. Anyway I am investigating the codes.

The reasons I thinking is

  1. RPC Clients are keep created.
  2. RPC Data is not sent properly and stored somewhere.
  3. Regex which determines file type are keep created.
HelloWorld017 commented 6 years ago

Imgur atom-discord: Disabled


Imgur atom-discord: Enabled Discord Client: Turned on


Imgur atom-discord: Enabled Discord Client: Turned off

HelloWorld017 commented 6 years ago

Could anyone check this issue persists after f41c42963fc8135c29419a9f6a8368717cb2fd6f?

mariosumd commented 6 years ago

I had the problem, and now, after almost 45 minutes running, I had no leakage.

xdavidhu commented 6 years ago

Okey, I can reproduce this on macOS, and its really bad.

Atom with atom-discord with Discord turned off: screen shot 2018-01-30 at 17 24 13

Atom with atom-discord with Discord turned on: (No need to reboot Atom, just started Discord) screen shot 2018-01-30 at 17 27 59

Atom is totally unsable on a Mac if Discord is not running. Its lagging to the point that you can't even scroll/type... :/

HelloWorld017 commented 6 years ago

Does this issue persist after setting interval to a very long-term? If this issue related to sending IPC packets, it will disappear because ipc won't be sent because of very long interval.

xdavidhu commented 6 years ago

No, even if I set a big interval (60 000ms) the CPU is still at 100%.

But when I start Discord up, the CPU goes down to 1%.

HelloWorld017 commented 6 years ago

That's interesting. I'll make start discord rpc client when the discord exists in the process list.

willowiscool commented 6 years ago

Any progress on this issue? Still getting it on macOS

HelloWorld017 commented 6 years ago

I think this error is related to discordjs/RPC#17 I'll try updating discord-rpc to latest.

If that does not fix issue, I'll make rpc not run when discord is not runnning manually.