Skip to content

Vec deallocation is extremely slow on Windows #18081

Closed
@nstoddard

Description

@nstoddard

On Windows, deallocation of Vecs is extremely slow, orders of magnitude slower than on Linux. I have some sample code below; after it prints "Initialized x...", it takes several seconds to deallocate x. If I use an array instead, it's nearly instantaneous on both platforms.

I'm using Windows 7, 64-bit, with 32-bit Rust.

Edit: If I pass the -O flag to rustc, it performs as expected. Still, I think this optimization is important enough that it might be worth enabling by default.

fn main() {
  let x = box Vec::from_elem(50000000, 5.0f32);
  // let x = box [5.0f32, ..50000000];

  println!("Initialized x with length: {}", x.len());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions