What's the maximum size of a Node.js Buffer
Maximum length of a typed array in V8 is currently set to kSmiMaxValue
which depending on the platform is either:
- 1Gb - 1byte on 32-bit
- 2Gb - 1byte on 64-bit
Relevant constant in the code is v8::internal::JSTypedArray::kMaxLength
(source).
V8 team is working on increasing this even further on 64-bit platforms, where currently ArrayBuffer
objects can be up to Number.MAX_SAFE_INTEGER
large (2**53 - 1). See bug 4153.
This is now documented as part of Node's buffer
api, the maximum size is buffer.constants.MAX_LENGTH
.
buffer.constants.MAX_LENGTH
<integer>
The largest size allowed for a single Buffer instance.
- On 32-bit architectures, this value is
(2^30)-1
(~1GB).- On 64-bit architectures, this value is
(2^31)-1
(~2GB).This value is also available as
buffer.kMaxLength
.
So you can figure out how big it is by doing
> (require('buffer').constants.MAX_LENGTH + 1) / 2**30
2