Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do ArrayBuffers have a maximum length?

I little confused here. Do ArrayBuffer allocate a new memory region for it? If so, what would be the safe maximum Blob size to put on it?

like image 550
cavila Avatar asked Jul 24 '13 00:07

cavila


People also ask

What is the maximum length of a message buffer?

The maximum buffer size for input/output is 32767 bytes.

Is Uint8Array same as ArrayBuffer?

Uint8Array – treats each byte in ArrayBuffer as a separate number, with possible values from 0 to 255 (a byte is 8-bit, so it can hold only that much). Such value is called a “8-bit unsigned integer”. Uint16Array – treats every 2 bytes as an integer, with possible values from 0 to 65535.

Is ArrayBuffer same as buffer?

The ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer. It is an array of bytes, often referred to in other languages as a "byte array".

What is Uint8Array used for?

The Uint8Array. from() method is used to create a new Uint8Array from an array-like or iterable object. So when you want to convert an arrayLike or iterable object then you can be used this function by passing the object as a parameter to this function along with map function and value used for map function if needed.


2 Answers

That only depends on your system and there doesn't seems to be a limit.

According to the specification :

If the requested number of bytes could not be allocated an exception is raised.

like image 152
Sebastien C. Avatar answered Sep 19 '22 08:09

Sebastien C.


what would be the safe maximum Blob size to put on it

There does not seem to be a hard limit, just whatever restrictions your platform imposes.

However, if one uses some sort of indexed access, indexes shouldn't be greater than Number.MAX_SAFE_INTEGER, because interesting bugs would happen otherwise.

Luckily, 2^53-1 bytes is around 8 petabytes so it shuoldn't be a concern unless you are doing something really weird.

like image 26
Daerdemandt Avatar answered Sep 19 '22 08:09

Daerdemandt