help icon indicating copy to clipboard operation
help copied to clipboard

RangeError: Array buffer allocation failed

Open fluentwind opened this issue 3 years ago • 3 comments

Version

12.22.0 32bit

Platform

windows 10 20H2 x64

Subsystem

No response

What steps will reproduce the bug?

const test = async function (b1) { b1 = Buffer.concat([b1, Buffer.from('\n')]) b1 = Buffer.concat([b1, Buffer.from('\n')]) b1 = Buffer.concat([b1, Buffer.from('\n')]) b1 = Buffer.concat([b1, Buffer.from('\n')]) return b1 } const test2 = async () => { let b1 = Buffer.alloc(1024 * 1024 * 300, '1') console.log(b1.length) b1 = await test(b1) console.log(b1.length) } test2()

How often does it reproduce? Is there a required condition?

Most time

What is the expected behavior?

Run successfully and print 314572800 314572804

What do you see instead?

UnhandledPromiseRejectionWarning: RangeError: Array buffer allocation failed at new ArrayBuffer () at new Uint8Array () at new FastBuffer (internal/buffer.js:951:1) at createUnsafeBuffer (buffer.js:152:12) at allocate (buffer.js:422:10) at Function.allocUnsafe (buffer.js:387:10) at Function.concat (buffer.js:567:25) at test (C:\Users\fluentwind\WebstormProjects\esign\test\testBuffer.js:3:15) at test2 (C:\Users\fluentwind\WebstormProjects\esign\test\testBuffer.js:11:14) at Object. (C:\Users\fluentwind\WebstormProjects\esign\test\testBuffer.js:14:1)

Additional information

I want to concat a buffer and get a full buffer.

But memory usage never goes down. Is there anything wrong with gc?

fluentwind avatar Jan 25 '22 06:01 fluentwind

Have you tried allocating a smaller buffer than 1024 * 1024 * 300? Looks like you do not have enough memory to handle your buffer size.

marsonya avatar Jan 26 '22 03:01 marsonya

@fluentwind - is this resolved?

gireeshpunathil avatar Jun 21 '22 03:06 gireeshpunathil

Hello, I'm using NextJS with webpack and got this issue when I run npm run dev. image image

Please let me know what is the issue and how to solve this. Thanks in advance!

darrylsepeda avatar Sep 05 '22 05:09 darrylsepeda

It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] avatar May 08 '24 01:05 github-actions[bot]

It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] avatar Jun 08 '24 01:06 github-actions[bot]