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 on Mac #43

Closed
cosmoduff opened this issue Oct 12, 2018 · 14 comments
Closed

Memory leak on Mac #43

cosmoduff opened this issue Oct 12, 2018 · 14 comments

Comments

@cosmoduff
Copy link

I am new to this so sorry if I am missing any information. When sending a notification on a separate thread a program will begin to consume more and more memory. This can be observed by writing a simple program that spawns a thread and then sends a notification from it. I suspect this issue may actually live in mac-notification-sys. I have observed this issue on macOS High Sierra.

Example:

extern crate notify_rust;

use notify_rust::Notification;
use std::thread::{sleep,spawn};
use std::time::Duration;

fn notify() {
   Notification::new()
       .summary("Firefox News")
       .body("This will look like a real notification.")
       .show()
       .unwrap();
}

fn main() {
    println!("Starting loop");
    loop{
        spawn(|| {
            println!("In the thread.");
            notify();
        });
        let dur = Duration::from_secs(5);
        sleep(dur);
    }
}
@hoodie
Copy link
Owner

hoodie commented Oct 13, 2018

thank you - @h4llow3En what do you think?

@h4llow3En
Copy link
Contributor

h4llow3En commented Oct 13, 2018

Did you tried it also on Linux systems? Or do you just noticed it on Mac?
Interestingly the memory usage seems to grow faster if build with the --release flag.
Also all spawned subprocesses seem to stay open.
This need some further investigation - @hoodie Are you able to confirm this on Linux as well?

@h4llow3En
Copy link
Contributor

Over the last 30 Minutes tested the script above using mac-notification-sys directly. The memory usage stayed consistent all the time.

@h4llow3En
Copy link
Contributor

Maybe you should upgrade mac-notification-sys in notify-rust. You are still using v0.1
Unfortunately this is not that easy. The used error crate failure is in conflict with error-chain.

@h4llow3En
Copy link
Contributor

Could be done with #44

@hoodie
Copy link
Owner

hoodie commented Oct 13, 2018

I didn't do that back then because the failure crate caused issues with dbus-rs. So I could probably update that along site. But I might have to ask for a backport of mac-notifications-sys using error-chain, just as a heads up. Thanks for looking into it though @h4llow3En 👍

@cosmoduff
Copy link
Author

@h4llow3En I haven't seen the issue on Linux systems. I've tested it on recently patched versions of Void Linux and Arch.

@h4llow3En
Copy link
Contributor

Yes a backport is a possible idea. But you also should consider changing to failure since error-chain seems to be deprecated (rust-lang-nursery/failure#181). If you wish I could have a look into that

@hoodie
Copy link
Owner

hoodie commented Oct 15, 2018

I am currently in the process of migrating to the latest dbus version, in the process of that I'm rewriting about 10% of the code. After that I can take some time to migrate it to failure. If you wish we could pair on that 😄 Any time this week[end] ?

@h4llow3En
Copy link
Contributor

Sure, if I find the time! 🙂 But I can't guarantee it

@cosmoduff
Copy link
Author

@h4llow3En I don't know if this will be helpful but the issue does not exist if the program is run with sudo or as root.

@mkroehnert
Copy link

Linking #49 and #50, since they seem to originate from this thread.
Hadn't seen this discussion before replying to the failure update ticket, but it would have helped understand the context better.

@hoodie
Copy link
Owner

hoodie commented May 12, 2019

the next release will have mac-notification-sys 0.3 will this solve the issue?
@cosmoduff

@cosmoduff
Copy link
Author

Sorry for the delay. Yes the issue does not exist in version 3.6. This issue can be closed. Thanks!

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

4 participants