bun icon indicating copy to clipboard operation
bun copied to clipboard

Memory Leak causing server to Crash

Open ironydips opened this issue 9 months ago • 1 comments

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 avatar May 07 '24 11:05 ironydips

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

ironydips avatar May 08 '24 03:05 ironydips

@ironydips is there any code for this we can run? as-is, this doesn't give us a way to investigate the issue

Jarred-Sumner avatar May 30 '24 23:05 Jarred-Sumner

We would love to help fix this, but we cannot without code to run that reproduces the issue.

Closing this since it's been 5 days without a reproduction, but feel free to leave a comment if you get one

Jarred-Sumner avatar Jun 04 '24 11:06 Jarred-Sumner