Closed liu798675179 closed 2 weeks ago
Sdk doesn't run any jobs in background and due to javascript's garbage collection mechanism, we don't provide destroy function that js will release memory automatically if variables/objects are not used anywhere.
Sdk doesn't run any jobs in background and due to javascript's garbage collection mechanism, we don't provide destroy function that js will release memory automatically if variables/objects are not used anywhere.
Yeah, that's the weirdest part. Let me monitor this carefully for a while longer.
When I comment out the business code in the function and only keep the initialization code of Raydium, and call the function regularly, the memory also increases slowly. When I comment out the relevant code of Raydium and call the function regularly, the memory tends to be stable. So it is likely that Raydium has similar scheduled tasks, event monitoring, closures, etc. after initialization? So it has been occupying resources and cannot be destroyed?
the only thing SDK might have is only watching token account changes here https://github.com/raydium-io/raydium-sdk-V2/blob/master/src/raydium/account/account.ts#L124, nothing else. if you don't need sdk watch token account change event, you can manage token account by yourself, example: updateTokenAccount and raydium UI also uses SDK v2 and don't have such problem
SDK code is open source you can review it (initialize code here: https://github.com/raydium-io/raydium-sdk-V2/blob/master/src/raydium/raydium.ts#L154), there's no jobs run inside , and if you also can check your code whether access data from sdk might cause closures, thx
Define the raydium instance in a function, which is used for swap transactions. Use load() to initialize the instance and pass in the owner field. The instance is not destroyed after the function is run. Account information is always requested regularly. When the function is called multiple times, the network will be congested and the memory will continue to accumulate.
After using the
raydium.account.updateTokenAccount(await fetchTokenAccountData())
method, the network congestion is resolved, but the memory is still slowly increasing, and it feels like there are still instances that have not been destroyed.@cruzshia @rudy5348 help me check it please, thanks.