Replies: 1 comment 1 reply
-
|
Not a huge amount of experience with usage patterns in JS, but in general I would not recommend allocating the max size up front. The recommendation in the spec is that size should be somewhere round 1GB, and this would make accidental resource exhaustion very easy with multiple contexts. I would suggest following a similar strategy to things like array-list resizing. I.e. expanding by some set factor to take you above the requested size. This tends to minimise copying in the all too common case where the buffer is repeatedly expanded up to some value, and then remains stable, but won't blow out the memory budget too quickly. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've been digging in to all the options for resizable array buffers, starting with our current PR from @anivar:
#2182
(FWIW, I would like to merge the work done in that PR so far with some additional fixes and tweaks.)
The intention of resizable array buffers is to make it possible for JavaScript programmers to efficiently create buffers that start small and grow as needed. Since we're on the JVM we don't have all the same options that native code has to allocate native memory.
For background, a resizable ArrayBuffer has an initial size and a maximum size, and a "resize" operation that changes the current size. And being JavaScript, all this affects the various TypedArray classes in weird and amazingly complicated ways.
There are two rough directions:
I am curious if anyone has experience with this newish JavaScript feature in production. Do you think we should:
Beta Was this translation helpful? Give feedback.
All reactions