You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an event loop created with Events::new(EventSettings::new()) , more and more meory is used up until the process aborts with an out of memory error. The problem can be avoided by switching to use window.next() instead.
Here's a reduced test case:
extern crate graphics;
extern crate opengl_graphics;
extern crate piston;
extern crate piston_window;
use opengl_graphics::OpenGL;
use piston::event_loop::*;
use piston::input::*;
use piston_window::{PistonWindow, WindowSettings};
const BLACK: [f32; 4] = [0.0, 0.0, 0.0, 1.0];
const WHITE: [f32; 4] = [1.0, 1.0, 1.0, 1.0];
fn main() {
let opengl = OpenGL::V3_2;
let mut window: PistonWindow = WindowSettings::new("maze", [800, 600])
.opengl(opengl)
.exit_on_esc(true)
.build()
.unwrap();
let mut events = Events::new(EventSettings::new());
while let Some(event) = events.next(&mut window) {
if let Some(_args) = event.render_args() {
window.draw_2d(&event, |c, gl| {
graphics::clear(BLACK, gl);
for _row in 0..72 {
for _col in 0..120 {
let color = WHITE;
let box_rect =
graphics::rectangle::rectangle_by_corners(0.0, 0.0, 10.0, 10.0);
graphics::rectangle(color, box_rect, c.transform, gl);
}
}
});
}
}
}
The program aborts in about 2 minutes after attempting to allocate 8GB. If events is removed and window.next() is used in the while loop instead, the problem goes away.
The text was updated successfully, but these errors were encountered:
When using an event loop created with
Events::new(EventSettings::new())
, more and more meory is used up until the process aborts with an out of memory error. The problem can be avoided by switching to usewindow.next()
instead.Here's a reduced test case:
The program aborts in about 2 minutes after attempting to allocate 8GB. If
events
is removed andwindow.next()
is used in the while loop instead, the problem goes away.The text was updated successfully, but these errors were encountered: