Skip to content

Possible memory leak when used with MongoDB #12117

@Akalanka47000

Description

@Akalanka47000

What version of Bun is running?

1.1.15

What platform is your computer?

Linux 5.10.214-202.855.amzn2.x86_64 x86_64 (Docker alpine image)

What steps can reproduce the bug?

I might be wrong here, but repeated calls to MongoDB through both mongoose and the driver skyrockets memory and CPU usage and doesn't seem to get reclaimed over time. After running out of options I ran the manual garbage collector at a recurring interval which reduced the rate at which memory is getting consumed but the issue still persists. The following drive link contains 3 heap snapshots taken from a running container at very short intervals :-

https://drive.google.com/file/d/1HG-68CdprR_nRwBkFInOOTBkS1VoneNA/view?usp=drive_link

Unfortunately, I do not possess enough knowledge to make head or tail of it except seeing the fact that the number of items in it increases, I would greatly appreciate it if someone could have a look when there's some free time on their hands

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

I managed to isolate all parts of the code and the following is observed :->

If i comment out the mongodb call and say I hardcode and return the same payload, memory usage doesn't increase whatever the number of requests I send

Once it's added back memory usage continues to increase and doesn't drop

I used JMeter to spam requests to test this, but even without spamming only on normal production request rates the behaviour is the same

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions