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

Memory leak with octet-streams #16529

Open
ScottUK opened this issue Jan 19, 2025 · 0 comments
Open

Memory leak with octet-streams #16529

ScottUK opened this issue Jan 19, 2025 · 0 comments
Labels
bug Something isn't working needs triage

Comments

@ScottUK
Copy link

ScottUK commented Jan 19, 2025

What version of Bun is running?

1.1.45+196621f25

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

In my project, I need to fetch a file from another site that returns an octet-stream, then pipe it to a file. The following code can re-produce this, where localhost:3000 is the site hosting the file I want to fetch:

const writeableStream = createWriteStream(`C:/temp/example.bin`);

const options = {
    hostname: 'localhost',
    port: '3000',
    path: `/files/example.bin`,
    method: 'GET'
};

http.get(options, (response) => {
    response.pipe(writeableStream);
});

writeableStream.on('finish', async () => {
    console.log('Finished writing file');
});

What is the expected behavior?

Memory usage should go up, but once the file is written the memory usage stays up instead of coming back down.

What do you see instead?

The memory usage still stays up, even if you call destroy on the writableStream etc. Bun.gc(true) and Bun.gc(false) does not help the issue.

Additional information

In my testing, I'm writing a 1GB testing.bin file, but the memory appears to go from 280MB at idle, to 3200MB, unsure if this is expected or not. I presumed it would only go to ~1280MB.

@ScottUK ScottUK added bug Something isn't working needs triage labels Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

1 participant