Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAM usage #88

Open
ravibrock opened this issue Apr 7, 2024 · 9 comments · Fixed by #63 or #100
Open

RAM usage #88

ravibrock opened this issue Apr 7, 2024 · 9 comments · Fixed by #63 or #100
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ravibrock
Copy link

Hey – thanks for making this nice tool. It seems to work well for the most part, but one issue I've noticed is that the memory usage seems to balloon over time. I'll attach a screenshot below; the two deno processes that to the best of my knowledge are solely related to the Apple Music RPC were using close to half a gigabyte of memory. Immediately after restarting with brew services restart apple-music-discord-rpc they were back down to ~100 megabytes total. I wanted to open the issue in case it was the result of a memory leak.

Before restarting the process:
Screenshot 2024-04-06 at 21 33 21

Immediately after restarting the process:
Screenshot 2024-04-06 at 21 37 58

@NextFire
Copy link
Owner

NextFire commented Apr 7, 2024

I can't really see anything in the script that would cause this memory leak. The only object that continues to grow during execution is the cache, but even then it wouldn't eat up half a gigabyte (and as we restore it after a restart, it would then take up the same amount of memory). 😕

@NextFire NextFire added bug Something isn't working help wanted Extra attention is needed labels Apr 7, 2024
@ravibrock
Copy link
Author

Thanks for the quick reply! That's weird. No worries if the bug can't be found. Not impossible that it's an issue with deno or my mac, but I can't imagine what it would be. Just in case, the logging info:

$ brew services info apple-music-discord-rpc
apple-music-discord-rpc (homebrew.mxcl.apple-music-discord-rpc)
Running: ✔
Loaded: ✔
Schedulable: ✘
User: root
PID: 69999

And the logfile was too large to attach (405k lines, ~30 megabytes) but this is the last 200k lines that I piped into their own file with tail.
music-rpc.log

@NextFire
Copy link
Owner

NextFire commented Apr 7, 2024

Oh I didn't realized that there were two deno processes, one of which is running as root. You should only brew service start the thing once, without sudo (unless you are also running Discord as root...).
These logs are just telling that the script cannot find the Discord socket (which is expected if the script is not running with the same user).

@ravibrock
Copy link
Author

ravibrock commented Apr 7, 2024

Ah, ok, thanks – I must have started one as root by accident. I've quit it now, but I just checked the working process and confirmed there's still the memory leak. Weird.

Screenshot 2024-04-07 at 00 32 43

@Doggies-Galore
Copy link

Doggies-Galore commented Apr 9, 2024

I am also experiencing the app memory ballooning over time. I checked the source and it could have something to do with prescense being started and stopped. Perhaps a cache (my best guess is Album Artwork or its web requests) is being held somewhere/not cleared when presence is stopped.

@Avakining
Copy link

This may not be fixed, at least not entirely. This is shown running 0.11.1 on macOS 14.6.1
Screenshot 2024-08-29 at 11 45 49
Screenshot 2024-08-29 at 11 47 45

@NextFire
Copy link
Owner

😕 well let's keep this issue open then

@NextFire
Copy link
Owner

NextFire commented Aug 31, 2024

I tried to profile the script with deno run -A --unstable --inspect music-rpc.ts and Chrome devtools.

I ran the script for 10 minutes, with the default timeout set to 100ms. I profiled the execution in the memory tab multiple times and haven't noted anything remarkable.

What's strange though is that despite having a quite stable / very slowly growing heap size usage around ~30mb, the RAM usage in Activity Monitor went from ~30mb at the start to ~100mb at the end of my session.

(Memory tab in devtools)
Screenshot 2024-08-31 at 09 58 44

(Activity Monitor)
Screenshot 2024-08-31 at 09 59 09

So I'm really not sure if there is something wrong with the script. Maybe there are some shenanigans in Deno's internal memory usage and its garbage collection but that's probably out of my scope / ability to profile.

@daronspence
Copy link

Just chiming in that I've seen this behavior as well for months. Updated to deno v2 today, so I will keep an eye on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
5 participants