Skip to content

possible memory leak? #16

Description

@polymorphicengine

Hi, I'm encountering what seems to be a slight memory leak (?) with flo_draw = "0.3.1" and flo_canvas = "0.3.1"). I'm trying to do a simple animation by looping the canvas.draw function. This will steadily consume memory (not a lot, only about 0.2 mega byte per second), but i want my application to be able to run for very long periods (days) and i'm worried it will run out of memory eventually. Here is a very simple piece of code that also produces the issue, am I doing something wrong?

use flo_canvas::*;
use flo_draw::*;

use std::thread;
use std::time::Duration;

pub fn main() {
    with_2d_graphics(|| {
        let canvas = create_drawing_window("Window");
        canvas.draw(|gc| {
            gc.clear_canvas(Color::Rgba(0.6, 0.7, 0.8, 1.0));
            gc.canvas_height(1000.0);
            gc.center_region(0.0, 0.0, 1000.0, 1000.0);
        });
        loop {
            canvas.draw(|gc| {
                gc.layer(LayerId(1));
                gc.clear_layer();
                gc.rect(0.0, 0.0, 100.0, 100.0);
                gc.fill_color(Color::Rgba(0.0, 0.0, 0.0, 1.0));
                gc.fill();
            });
            thread::sleep(Duration::from_nanos(1_000_000_000 / 60));
        }
    });
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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