Skip to content

Buffer constructor not allocating at pool #42821

Description

@maximelkin

Affected URL(s)

https://nodejs.org/dist/latest/docs/api/buffer.html#static-method-bufferallocunsafesize

Description of the problem

The Buffer module pre-allocates an internal Buffer instance of size Buffer.poolSize that is used as a pool for the fast allocation of new Buffer instances created using ...blah blah..., and the deprecated new Buffer(size) constructor ...blah blah..

This behaviour changed at 7eb1b46 (v8.0.0), new Buffer(size) will never use preallocated pool.

Activity

  1. added
    docIssues and PRs related to Node.js documentation.
    on Apr 22, 2022
  2. added
    bufferIssues and PRs related to the buffer subsystem.
    on Apr 22, 2022
  3. jasnell commented on Apr 22, 2022

    @jasnell
    Member

    Looks like just a documentation bug. Interested in opening a pull request? :-)

  4. maximelkin commented on Apr 23, 2022

    @maximelkin
    Author

    Wait, I'm not sure. This commit actually about zero-filling, new Buffer() can actually allocate at internal pool, excluding case when passing number as argument. So strings & arrays - still can be allocated at internal pool (with same restrictions about size).

    Not sure how to formulate this clearly & understandable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.docIssues and PRs related to Node.js documentation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions