tc39 / proposal-oom-fails-fast

Proposal: Out of memory immediately terminates agent cluster
Apache License 2.0
13 stars 4 forks source link

Provide a mechanism to allow attempting a segment of code that could OOM, with the ability to fall back in case it does. #5

Open dead-claudia opened 3 years ago

dead-claudia commented 3 years ago

This would be valuable for very large allocations where you don't want to crash the application or page, but instead display an error or otherwise tolerate such failure.

erights commented 2 years ago

I don't understand the title of this issue. Could you clarify? Thanks.

dead-claudia commented 2 years ago

Something like this:

try {
    const foo = new Uint8Array(1*1024*1024*1024)
} catch out of memory somehow {
    // display an error or maybe try with a smaller chunk size
}

Stuff like downloading files to decrypt using Web Crypto (which lacks a streaming API and has been dragging their feet for well over a year despite the demand and precedent) and large image/video processing come to mind.

Regarding language precedent, here's a few I found in a few minutes of searching: