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 when creating a new window #357

Open
shassen14 opened this issue Aug 5, 2024 · 1 comment
Open

Memory leak when creating a new window #357

shassen14 opened this issue Aug 5, 2024 · 1 comment

Comments

@shassen14
Copy link

I noticed a small memory leak while developing and tracked it down partially due to when creating a new window. Here is an example code which valgrind detects a memory leak. I am on Ubuntu 22.04 testing this.

use minifb::{Window, WindowOptions};

const W: usize = 800;
const H: usize = 400;

fn main() -> Result<(), std::io::Error> {
    let _window = Window::new(
        &"Here is a title".to_string(),
        W,
        H,
        WindowOptions::default(),
    );

    Ok(())
}

The output text from valgrind is attached here.
test_minifb.txt

Valgrind states there is 244 bytes lost in this program, but the program I was developing was integrating minifb and plotters stated there was 500 bytes lost. I am currently trying to track down the other 256 bytes (and also if it grows over time).

If there is something I am doing wrong or more information needed, I would greatly appreciate any feedback. Thank you so much for your work!

@emoon
Copy link
Owner

emoon commented Aug 9, 2024

Thanks for the report. It might be related to some resources that isn't freed correctly during the close down of the Window. While not ideal as long as it doesn't keep leaking while running it shouldn't be a major issue as the OS will clean up the resources afterwards.

That being said it would be nice to fix it if possible.

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

2 participants