Experimenting with memory pool pre-allocation, I found that allocating a 60M Float32Array makes sometimes crash the browser tab (tried in Chrome):
var bigArray = new Float32Array(60000000)
for (var i = 0; i < bigArray.length; i+=1) {
bigArray[i] = Math.random()
}
I'm allocating 240MB in total (i.e. Float32Array.BYTES_PER_ELEMENT * bigArray.length) on an 8Gb machine. That makes the tab crash 20% of times, and 100% if I try to inspect bigArray (e.g., try to get bigArray.length in console, log it or, worse, hover over it to see its contents).
Is there a way (nonstandard, complex at will) in modern browsers (mainly Firefox and Chrome) to calculate the allocation limit? I would like to preallocate a pool near the limit and use that pool for all my subsequent float array needs - I don't strictly need to allocate a 60M Float32Array, but I would like to figure out the maximum reasonable pool I can try to allocate without thrashing my tab.
chrome://memory-redirect/,chrome://profiler/see chromium.org/developers/memory-usage-backgrounder , chromium.org/developers/memory-bloat , chromium.org/developers/threaded-task-trackingperformance.memorytells you what you're using in chrome, and includes a property "jsHeapSizeLimit", but i don't know if that includes such arrays. i think the default V8 limit was/is 512MB...