I have a significant memory leak (running 8 Jest t...
# prisma-client
b
I have a significant memory leak (running 8 Jest threads uses ~22GB of RAM in total, across ~700 tests) in my tests, and I believe it's due to my usage of Prisma The issue seems to be that each test uses its own instance of
PrismaClient
, each of which hangs on to some memory even after
$disconnect
is called This appears to be backed up by the warning messages that I get saying
Already 10 Prisma Clients are actively running
I'd expect
$disconnect
to kill and release the memory of the underlying engine instance, but I assume there's a good reason why this isn't done What's the recommended way of handling this please? Sadly it's private code so I can't link to a repo, but I'm happy to provide any requested details where possible
👀 1
b
Thanks @Ramon Pans! That got rid of the warning, but it seems that my theory about this being the cause of the memory leak is incorrect, as it's still present Time to start inspecting memory dumps I guess 🙂
👍 1
r
Glad I could help, good luck!!
👍 1
r
@Ben Ezard 👋 How many tests are you running in parallel?
b
@Ryan 👋 I'm currently running 8 tests in parallel, but I still have the memory leak when I run the tests in a single thread
r
Let me know if you could reproduce this on a separate repo. Usually running
$disconnect()
should be enough.
b
Thanks @Ryan, I'll see if I can setup a repro repo for this then 👍
🙌 1