tursodatabase / libsql-client-ts

TypeScript/JavaScript client API for libSQL
https://docs.turso.tech/sdk/ts/quickstart
MIT License
189 stars 30 forks source link

@libsql/client embedded replica leaks memory #135

Open khuezy opened 7 months ago

khuezy commented 7 months ago

Hi! There is a major memory leak when using embedded replicas (calling client.sync and then making any query on the client). The reproduction repo is here with instructions.

Here is a screenshot of the Fly container memory (using sync) At the 13:24:00 mark, the load test is executed. Memory continues to grow and flat lines after the test ends (most of the memory is never released). NOTE: and 2nd container was created (13:27:00) b/c the 1st almost ran out of memory image

Here is a screenshot of the same app but w/o using embedded replicas: At the 13:53:00 mark, the load test is executed. Memory never explodes and stays leveled. At the end of the test, the memory is freed (there's a slight difference from the start/end, but that's just normal node GC behavior... sometimes the ending memory is less than the starting memory) image (1)

LucioFranco commented 7 months ago

cc @psarna @MarinPostma

MarinPostma commented 7 months ago

maybe linked to: https://ptb.discord.com/channels/933071162680958986/1175813081717280900/1175813081717280900

khuezy commented 7 months ago

Yes that looks like it's related. Perhaps it's not embedded replicas, but a local file that causing the leak.