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

memory leak? #549

Closed
Xtr4F opened this issue Aug 22, 2024 · 6 comments
Closed

memory leak? #549

Xtr4F opened this issue Aug 22, 2024 · 6 comments

Comments

@Xtr4F
Copy link

Xtr4F commented Aug 22, 2024

RAM usage is growing uncontrollably when using Utils.interval. it looks like it's a problem with hyprland.messge() (and .messageAsync() as well, which is causing this to happen. I've tried using Utils.exec() alternatively and haven't noticed this behavior. Video below:

vid.mp4

P.s. 1 millisecond interval for clarity. In reality, even with interval values like 100, memory usage grows, just a bit slower, but it is never freed, even when the interval is already destroyed.

@Xtr4F
Copy link
Author

Xtr4F commented Aug 22, 2024

P.s.s. At the time of writing this issue, ags crashed with an error, filling about 770mb of memory, lol:
image

@Xtr4F
Copy link
Author

Xtr4F commented Aug 22, 2024

So, I did a little investigation (ran 4 different ags instances with different interval times, the first two with 5ms, the last two with 50ms. The first and third call hyprland.message, the second and fourth call Utils.exec) and it turns out that all of them increase memory usage over time for some JavaScript reason I don't understand, just at different speeds:

изображение

But now I'm even more confused as why in the world this is happening?

Well ok, in many cases it's not that critical since you won't run it infinitely, but the problem is that it doesn't free memory even when the interval is destroyed (or I'm doing something wrong, I'm a noob in JS), which can already lead to some bad consequences

@Xtr4F Xtr4F changed the title hyprland.message() memory leak? memory leak? Aug 22, 2024
@its-darsh
Copy link

does printing the output directly (without passing into the json parser) trigger the GC?

might be a leak in the JSON parser

@Xtr4F
Copy link
Author

Xtr4F commented Aug 24, 2024

No, it doesn't. And memory leak happens only with Utils and Services methods like Utils.exec, Utils.execAsync, Utils.fetch , hypland.message, etc

@Xtr4F
Copy link
Author

Xtr4F commented Aug 25, 2024

upd. The only solution I've come up with so far is to use an external script. But Utils.subprocess() also causes a leak. So I use Variable instead. And for some reason it works fine. I left this code running for about an hour and RAM usage never once went over 60mb:

pic

It really seems to be a problem with some parts of Utils and Services 🤔

@Xtr4F
Copy link
Author

Xtr4F commented Aug 26, 2024

What's even weirder is that I have looked at the sources and Variable also uses subprocess but doesn't cause this problem:

2024-08-26.12-06-38.mp4

@Aylur Aylur mentioned this issue Sep 25, 2024
Merged
@Aylur Aylur closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants