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

Buffer constructor not allocating at pool #42821

Closed
maximelkin opened this issue Apr 22, 2022 · 2 comments · Fixed by #48183
Closed

Buffer constructor not allocating at pool #42821

maximelkin opened this issue Apr 22, 2022 · 2 comments · Fixed by #48183
Labels
buffer Issues and PRs related to the buffer subsystem. doc Issues and PRs related to the documentations.

Comments

@maximelkin
Copy link

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.

@maximelkin maximelkin added the doc Issues and PRs related to the documentations. label Apr 22, 2022
@VoltrexKeyva VoltrexKeyva added the buffer Issues and PRs related to the buffer subsystem. label Apr 22, 2022
@jasnell
Copy link
Member

jasnell commented Apr 22, 2022

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

@maximelkin
Copy link
Author

maximelkin commented Apr 23, 2022

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.

nodejs-github-bot pushed a commit that referenced this issue May 29, 2023
PR-URL: #48183
Fixes: #42821
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
targos pushed a commit that referenced this issue May 30, 2023
PR-URL: #48183
Fixes: #42821
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
danielleadams pushed a commit that referenced this issue Jul 6, 2023
PR-URL: #48183
Fixes: #42821
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
MoLow pushed a commit to MoLow/node that referenced this issue Jul 6, 2023
PR-URL: nodejs#48183
Fixes: nodejs#42821
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this issue Aug 14, 2023
PR-URL: nodejs#48183
Fixes: nodejs#42821
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this issue Aug 14, 2023
PR-URL: nodejs#48183
Fixes: nodejs#42821
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants