-
Notifications
You must be signed in to change notification settings - Fork 421
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 (probably command encoders not getting cleaned up) #1128
Comments
I can't seem to repro. note that the logger is spamming the terminal with info logs |
It seems like the system memory is going up (the games process that is) |
Can you remove the logger and see if it still happens? |
Hi, yes even without the logger the (system) memory leak still exists |
I think I can repro on Windows 10. |
possibly related to gfx-rs/wgpu#2553 |
didn't check how that works exactly but the buffers can probably be deleted post-frame when strong = 1 |
Growing arena doesn't cause this issue - deleting grown buffers every frame doesn't help (e.g., for all the examples, the arena reaches a stable point after frame 1) |
use std::env;
use std::str::FromStr;
use ggez::{
event,
glam::*,
graphics::{self, Color},
Context, GameResult,
};
struct MainState {
count: u64,
circles_per_draw: u64,
}
impl event::EventHandler<ggez::GameError> for MainState {
fn update(&mut self, _ctx: &mut Context) -> GameResult {
Ok(())
}
fn draw(&mut self, ctx: &mut Context) -> GameResult {
self.count += 1;
let mut canvas =
graphics::Canvas::from_frame(ctx, graphics::Color::from([0.1, 0.2, 0.3, 1.0]));
for _ in 0..self.circles_per_draw {
let circle = graphics::Mesh::new_circle(
ctx,
graphics::DrawMode::fill(),
vec2(0., 0.),
100.0,
2.0,
Color::WHITE,
)?;
canvas.draw(&circle, Vec2::new(0., 380.0));
}
canvas.finish(ctx)?;
if self.count > (60 * 60) { // run for 1m, assuming 60fps
ctx.request_quit();
}
Ok(())
}
}
pub fn main() -> GameResult {
let mut numbers = Vec::new();
for arg in env::args().skip(1) {
numbers.push(u64::from_str(&arg)
.expect("error parsing argument"));
}
if numbers.len() == 0 {
eprintln!("Usage: no arg given");
std::process::exit(1);
}
let cb = ggez::ContextBuilder::new("super_simple", "ggez");
let (ctx, event_loop) = cb.build()?;
let state = MainState {count: 0, circles_per_draw: numbers[0]};
event::run(ctx, event_loop, state)
} I ran this, passing in 10 and 100 as an argument, with valgrind, which returned the following With 10
With 100
So whatever's going on doesn't seem to scale with the number of meshes dropped, at least on my machine. |
The output is long with possible losses but here's the stuff that valgrind thinks is definitely lost
|
Same leak i my project, except I'm not useing Mesh. |
Can anyone confirm this is still happening on devel with latest rust compiler nightly? I'm having trouble reproducing. |
@Vixeliz i am using the latest nightly and the devel branch of this repo
I can still see the increase in system memory usage
I am using linux with x11 and nvidia proprietary drivers |
Describe the bug
Meshes are not cleaned up after they go out of scope
To Reproduce
Create a Mesh and drop it
Expected behavior
The mesh should be dropped on the GPU
Screenshots or pasted code
Adapted from the "super_simple" example
Hardware and Software:
The text was updated successfully, but these errors were encountered: