What is safety consern about Uint32Array::view exactly? #3802
-
There is this text in the docs:
Can anyone explain what this means exactly. How can
than my array will be valid indefinitely (assuming I don't care about memory leak here). Do I get something wrong about memory management in wasm? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The problem is that See https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Memory/grow#detachment_upon_growing (that's talking about |
Beta Was this translation helpful? Give feedback.
The problem is that
Box::new
might cause Wasm memory to get bigger, and when it does that all the existing references in JS get replaced with emptyUint8Array
s ('detached').See https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Memory/grow#detachment_upon_growing (that's talking about
Memory.grow
in JavaScript, when it's thememory.grow
instruction that gets used byBox
, but it works the same way).