grow()
protoype method of the
Memory
object increases the size of the memory instance by a specified number of WebAssembly pages.
memory.grow(number);
The number of WebAssembly pages you want to grow the memory by (each one is 64KiB in size).
The previous size of the memory, in units of WebAssembly pages.
The following example creates a new WebAssembly Memory instance with an initial size of 1 page (64KiB), and a maximum size of 10 pages (640KiB).
var memory = new WebAssembly.Memory({initial:1, maximum:10});
We can then grow the instance by one page like so:
const bytesPerPage = 64 * 1024; console.log(memory.buffer.byteLength / bytesPerPage); // "1" console.log(memory.grow(1)); // "1" console.log(memory.buffer.byteLength / bytesPerPage); // "2"
Note the return value of
grow()
here is the previous number of WebAssembly pages.
| 规范 |
|---|
|
WebAssembly JavaScript 接口
The definition of 'grow()' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
grow
|
Chrome 57 | Edge 16 |
Firefox
52
|
IE No | Opera 44 | Safari 11 | WebView Android 57 | Chrome Android 57 |
Firefox Android
52
|
Opera Android 43 | Safari iOS 11 | Samsung Internet Android 7.0 | nodejs 8.0.0 |
完整支持
不支持
见实现注意事项。
WebAssembly
WebAssembly.Module
WebAssembly.Global
WebAssembly.Instance
WebAssembly.Memory
WebAssembly.Table
WebAssembly.CompileError
WebAssembly.LinkError
WebAssembly.RuntimeError
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()