Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: update buffer.constants.MAX_LENGTH #38109

Closed
wants to merge 4 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -3410,12 +3410,26 @@ added: v8.2.0
#### `buffer.constants.MAX_LENGTH`
<!-- YAML
added: v8.2.0
changes:
- version: v15.0.0
pr-url: https://github.com/nodejs/node/pull/35415
description: Value is changed to 2<sup>32</sup> (~4GB) on 64-bit
jasnell marked this conversation as resolved.
Show resolved Hide resolved
architectures.
- version: v14.0.0
pr-url: https://github.com/nodejs/node/pull/32116
description: Value is changed to 2<sup>32</sup> - 1 (~4GB) on 64-bit
architectures.
jasnell marked this conversation as resolved.
Show resolved Hide resolved
-->

* {integer} The largest size allowed for a single `Buffer` instance.

On 32-bit architectures, this value currently is 2<sup>30</sup> - 1 (~1GB).
On 64-bit architectures, this value currently is 2<sup>31</sup> - 1 (~2GB).

On 64-bit architectures, this value varies from Node.js version to version.
It is at least 2<sup>31</sup> - 1 (~2GB) and currently is 2<sup>32</sup>
(~4GB). See history for detail.
jasnell marked this conversation as resolved.
Show resolved Hide resolved

It reflects [`v8::TypedArray::kMaxLength`][] under the hood.

This value is also available as [`buffer.kMaxLength`][].

Expand Down Expand Up @@ -3585,6 +3599,7 @@ introducing security vulnerabilities into an application.
[`buffer.constants.MAX_STRING_LENGTH`]: #buffer_buffer_constants_max_string_length
[`buffer.kMaxLength`]: #buffer_buffer_kmaxlength
[`util.inspect()`]: util.md#util_util_inspect_object_options
[`v8::TypedArray::kMaxLength`]: https://v8.github.io/api/head/classv8_1_1TypedArray.html#a54a48f4373da0850663c4393d843b9b0
[base64url]: https://tools.ietf.org/html/rfc4648#section-5
[binary strings]: https://developer.mozilla.org/en-US/docs/Web/API/DOMString/Binary
[endianness]: https://en.wikipedia.org/wiki/Endianness
Expand Down