Files
node/test/wasm-allocation/test-wasm-allocation.js

22 lines
742 B
JavaScript

// RLIMIT_AS: 21474836480
// With 20GB virtual memory, there's enough space for the first few wasm memory
// allocation to succeed, but not enough for many subsequent ones since each
// wasm memory32 with guard regions reserves 8GB of virtual address space.
'use strict';
require('../common');
const assert = require('assert');
// The first allocation should succeed.
const first = new WebAssembly.Memory({ initial: 10, maximum: 100 });
assert(first);
// Subsequent allocations should eventually fail due to running out of
// virtual address space.
assert.throws(() => {
const instances = [first];
for (let i = 1; i < 30; i++) {
instances.push(new WebAssembly.Memory({ initial: 10, maximum: 100 }));
}
}, /WebAssembly\.Memory/);