Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak executing UnsignedTransaction.to_json() #641

Open
ThierryM1212 opened this issue Oct 10, 2022 · 3 comments
Open

Memory leak executing UnsignedTransaction.to_json() #641

ThierryM1212 opened this issue Oct 10, 2022 · 3 comments

Comments

@ThierryM1212
Copy link

Trying to sign transactions in a loop, the UnsignedTransaction to_json method does not free the memory used.

Attaching a test case ran with nodejs.

mem-leak.txt

@ross-weir
Copy link
Collaborator

Not sure why you would want to do something like this but its likely caused by the infinite blocking loop, you can achieve a similar effect with no memory leak by doing:

setInterval(async () => {
    const unsignedTransaction = (await ergolib).UnsignedTransaction.from_json(JSON.stringify(tx));
    let txJSON = unsignedTransaction.to_json();
    unsignedTransaction.free();
}, 0)

@ThierryM1212
Copy link
Author

ThierryM1212 commented Dec 12, 2022

Thanks for looing at the issue.

The initial code that was having memory leaks was for the CYTI miner and it is not used anymore:
ThierryM1212/cyti@0985b33#diff-ce78f2b518451890a837e00f6508b5533e07dcbdc52c97c4be28a9271bbdaac4R116
It is iterating with a nonce in a register to try to find the required sequence for the begining of the boxId.

To find it I've removed iteratively all the code until it stop to memleaks.
Running with --inspect option, an ArrayBuffer is always growing, it has references to wasm objects.

In other off-chain bots, for Blob's Topia, I'm also facing memory leaks after having taken care of freeing the resources.
The action are trigerred here by "setInterval".
https://github.com/ThierryM1212/blobs-topia/blob/main/blobs-bot/fight-bot.js

I will try to extract another minimal test case.

@ross-weir
Copy link
Collaborator

Ohh I see

I will try to extract another minimal test case.

Sounds good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants