libsql-client-ts icon indicating copy to clipboard operation
libsql-client-ts copied to clipboard

@libsql/client embedded replica leaks memory

Open khuezy opened this issue 2 years ago • 3 comments

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)

khuezy avatar Nov 21 '23 22:11 khuezy

cc @psarna @MarinPostma

LucioFranco avatar Nov 21 '23 22:11 LucioFranco

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

MarinPostma avatar Nov 22 '23 10:11 MarinPostma

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

khuezy avatar Nov 22 '23 15:11 khuezy