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

Creating tiny reusable buffers runs out of memory #8000

Open
domoritz opened this issue Jan 5, 2024 · 4 comments
Open

Creating tiny reusable buffers runs out of memory #8000

domoritz opened this issue Jan 5, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@domoritz
Copy link

domoritz commented Jan 5, 2024

What version of Bun is running?

1.0.19+906f86d6f

What platform is your computer?

Darwin 23.4.0 arm64 arm

What steps can reproduce the bug?

> bun repl
Welcome to Bun v1.0.19
Type ".help" for more information.
[!] Please note that the REPL implementation is still experimental!
    Don't consider it to be representative of the stability or behavior of Bun overall.
> const a = new ArrayBuffer(0, {maxByteLength: 4294967295})
undefined
> const b = new ArrayBuffer(0, {maxByteLength: 4294967295})
undefined
> const c = new ArrayBuffer(0, {maxByteLength: 4294967295})
undefined
> const d = new ArrayBuffer(0, {maxByteLength: 4294967295})
undefined
> const e = new ArrayBuffer(0, {maxByteLength: 4294967295})
undefined
> const f = new ArrayBuffer(0, {maxByteLength: 4294967295})
undefined
> const g = new ArrayBuffer(0, {maxByteLength: 4294967295})
undefined
> const h = new ArrayBuffer(0, {maxByteLength: 4294967295})
1 | "use strict";void 0;
2 | const h = new ArrayBuffer(0, {
    maxByteLength: 4294967295
});
              ^
RangeError: Out of memory

>

What is the expected behavior?

The program should not run out of memory. https://stackoverflow.com/questions/77029625/memory-allocated-for-resizeable-javascript-arraybuffer explains that the memory should not be allocated and my buffers are all of size 0.

What do you see instead?

No response

Additional information

No response

@domoritz domoritz added the bug Something isn't working label Jan 5, 2024
@Electroid
Copy link
Contributor

Interesting, it’s possible that instead of setting the max length, it is actually allocating that much up front.

@domoritz
Copy link
Author

domoritz commented Jan 5, 2024

That could be the case but that would be problematic since that somewhat defeats the purpose of a resizable buffer.

@domoritz domoritz changed the title Creating reusable buffers runs out of memory Creating tiny reusable buffers runs out of memory Jan 5, 2024
@domoritz
Copy link
Author

domoritz commented Jan 14, 2024

Can you confirm that this is a bug? We are making an Apache Arrow release soon and it's using reusable buffers by default. If this isn't a bug, I would want to revert the feature asap. Right now, we don't have many bun users so this issue isn't a release blocker.

@domoritz
Copy link
Author

Oh, looks like Safari has the same issue so this might be a blocker.

Screenshot 2024-01-14 at 17 27 08

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants