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

Potential Memory Leak in tasklist Usage (looping process list) #6

Open
xh0 opened this issue May 30, 2024 · 0 comments
Open

Potential Memory Leak in tasklist Usage (looping process list) #6

xh0 opened this issue May 30, 2024 · 0 comments

Comments

@xh0
Copy link

xh0 commented May 30, 2024

I'm using the tasklist crate to list running processes in a loop. Here's a minimal example showcasing the issue:

use tasklist;

fn main() {
    loop {
        std::thread::sleep(std::time::Duration::from_millis(10_000));
        unsafe {
            let tl = tasklist::Tasklist::new();
            for i in tl {
                println!("{} {} {}", i.get_pid(), i.get_pname(), i.get_user());
            }
        }
    }
}

I've observed that the memory usage of this application keeps increasing over time. This leads me to believe there might be a memory leak in how the tasklist crate is being used.

Additional Information:

I'm using tasklist version 0.2.13.
I've included a minimal example to isolate the issue.

Possible Cause:

I'm not entirely sure, but the usage of unsafe block and the loop might be causing the leak. The tasklist crate might be allocating memory for each iteration that's not being properly released.

Request:

I'd appreciate it if you could investigate this potential memory leak. If it's confirmed, any suggestions on how to use tasklist more efficiently or alternative approaches to achieve the same functionality would be helpful.

Thank you!

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

1 participant