oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
71.09k stars 2.47k forks source link

Memory Leak causing server to Crash #10893

Open ironydips opened 1 week ago

ironydips commented 1 week ago

What version of Bun is running?

1.1.7+b0b7db5c0

What platform is your computer?

Linux 6.8.0-1008-aws x86_64 x86_64

What steps can reproduce the bug?

Overview: Running pm2 with 10 instance of our application causing huge memory leak. We are running the cpu intensive app (that has 2 workers inside it). We have created 10 instances of app and managing through pm2.

I am the only one using This server to test bun on production. After running some tests for first 2 minutes, I saw that memory went up and never came down.

Ran same app using node, and memory went down in few seconds.

you can see in below screenshot that pm2 is up & idle for last 6 minutes and memeory consumption of each instance is above 3 gb (crazy high)

Screenshot 2024-05-07 at 5 11 25 PM

Below is the screenshot of htop at that time

Screenshot 2024-05-07 at 5 25 38 PM

Am i missing anything?

I just ran this command

for bun: pm2 start "PORT=3002 bun index.js" & pm2 start "PORT=3003 bun index.js" & pm2 start "PORT=3004 bun index.js" & pm2 start "PORT=3005 bun index.js" & pm2 start "PORT=3006 bun index.js" & pm2 start "PORT=3007 bun index.js" & pm2 start "PORT=3008 bun index.js" & pm2 start "PORT=3009 bun index.js" & pm2 start "PORT=3010 bun index.js"

for node: pm2 start "PORT=3002 node index.js" & pm2 start "PORT=3003 node index.js" & pm2 start "PORT=3004 node index.js" & pm2 start "PORT=3005 node index.js" & pm2 start "PORT=3006 node index.js" & pm2 start "PORT=3007 node index.js" & pm2 start "PORT=3008 node index.js" & pm2 start "PORT=3009 node index.js" & pm2 start "PORT=3010 node index.js"

What is the expected behavior?

Memory should be released as soon as its work is done, just like how its being done in node environment.

What do you see instead?

Memory not being released and is a big blocker for us to move to production.

Additional information

No response

ironydips commented 1 week ago

@Jarred-Sumner : would appreciate if you can take a look pls. is it a known issue because of worker?