drift-labs/protocol-v2

TS SDK Memory Leak

solserer-labs opened this issue · 3 comments

System: Ubuntu 20
RAM: 4GB

Tried with node versions 19, 18 and 16.

The drift client subscription and has a memory leak. Subscribing leads to a constant increase in memory until the nodejs process dies.

Sample code that subscribes and waits. After 10 or so minutes the process has accumulated 300MB more in memory usage.

    const wallet = new Wallet(await getSolanaKeypair("secrets"))
    console.log("Loaded keypair with address:", wallet.publicKey.toBase58())
    const connection = new Connection("")
    const driftClient = new DriftClient({
        connection,
        wallet,
        env: 'mainnet-beta',
    });
    await driftClient.subscribe();
    while (true) {
        try {
            console.log("waiting")
            await new Promise(r => setTimeout(r, 5000));
           
        } catch (error) {
            console.log(error)
        }
        await new Promise(r => setTimeout(r, 60000));
    }
}
0xbigz commented

thanks for sharing, will investigate

Awesome. Ping when/if you got a fix or if you can't replicate, happy to help!

which version of the sdk are you using?