-
Notifications
You must be signed in to change notification settings - Fork 4
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
Response.file
has a memory leak
#13
Comments
Yep. If I change the file to use this instead I get no leaks. const pocFile = readFileSync('assets/poc.html', 'utf-8');
const memoryLeak = () => pocFile; and even if I use the const pocFile = readFileSync('assets/poc.html', 'utf-8');
const memoryLeak = () => new Response(pocFile, {
headers: {
'Content-Type': 'text/html; charset=utf-8',
}
}); |
@sstur would you mind looking at this as it currently makes the framework somewhat unusable. 😢 |
I wasn't able to get to this yet, but thanks for your patience, will dig in as soon as I can carve out the time. |
I wonder if it's this issue oven-sh/bun#1824 (comment) |
This should be retested on the newest bun canary release. |
Do you know if this was fixed in bun core or if it's still an issue? |
Save this as
src/poc.ts
.Save this as
assets/poc.html
Start the server in one terminal with
bun run ./src/poc.ts
and then in a second terminal start the benchmark withbunx autocannon http://localhost:3000/no-memory-leak -c 1000
Notice a small memory increase but then it stabilises. You can run this as many time as you want after this and the memory will barely move a few MB if that.
If you now run
bunx autocannon http://localhost:3000/memory-leak -c 1000
you'll see the memory creeps up into the 100s of MB and stays there. Every time you re-run it you'll keep seeing more and more memory usage.The text was updated successfully, but these errors were encountered: