title: Why does Chrome eventually throw "Out of memory: wasm memory" after repeatedly refreshing a page that uses WebAssembly?
body: <p>I would like to believe that refreshing a browser window or tab cannot leak. Unfortunately, this does not appear to be the case when WebAssembly is concerned.</p>
  
  <p>I have built a WebAssembly crate with Rust. The compiled size of the crate is approximately 360 Kb (prior to content compression) and the crate works just fine in Firefox and even on Safari on iOS. However, I am having numerous issues in Chrome, one of them being that refreshing the page that uses the <code>.wasm</code> eventually leads to an out-of-memory error in the Console.</p>
  
  <p>The page works fine for about 35 refreshes and then throws the following:</p>
  
  <pre><code>Uncaught (in promise) RangeError: WebAssembly Instantiation: Out of memory: wasm memory
  </code></pre>
  
  <p>After this, the tab is useless but opening a new tab and loading the page works as expected -- again, for about the first 35 refreshes.</p>
  
  <p>Is this a bug in the browser or am I doing something wrong in my code? If it is a bug, is there any way to work around it? (Not that I expect that it will manifest itself in production but anyway...)</p>
  
  <p>(Presumably, the promise mentioned in the error message is the one returned by <code>import('...')</code>. I am using webpack and so I am affected by <a href="https://github.com/webpack/webpack/issues/6615" rel="nofollow noreferrer">https://github.com/webpack/webpack/issues/6615</a> )</p>