Skip to content

Memory leak when creating a new window #357

@shassen14

Description

@shassen14

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions