<p dir="auto">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.</p>
<p dir="auto">I'm using Windows 7, 64-bit, with 32-bit Rust.</p>
<p dir="auto">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.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fn main() {
  let x = box Vec::from_elem(50000000, 5.0f32);
  // let x = box [5.0f32, ..50000000];

  println!(&quot;Initialized x with length: {}&quot;, x.len());
}"><pre class="notranslate"><code class="notranslate">fn main() {
  let x = box Vec::from_elem(50000000, 5.0f32);
  // let x = box [5.0f32, ..50000000];

  println!("Initialized x with length: {}", x.len());
}
</code></pre></div>
<p dir="auto">The internal representation of String is <code class="notranslate">Vec&lt;u8&gt;</code>, but <code class="notranslate">vec.truncate</code> loops to drop members.</p>
<p dir="auto">Perhaps setting the length directly?</p>