-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Possible closure leak in web3.eth.Contract 1.x ? #3042
Comments
Same problem with "web3.js: v2.0.0-alpha". In this version it seems to be not due to a closure leak, but probably due to the following line: https://github.com/ethereum/web3.js/blob/2.x/packages/web3-eth/src/Eth.js#L107 Version
|
Hey Samuel, thx for the quick answer. web3.eth.net.isListening() does also seem to increase the memory. Version
|
Thanks for the response @nivida. I'm certain that numerous production systems that use web3.js are affected by it, like we were, it's fully understandable there are issues since the project development is very active and production systems shouldn't expect web3.js to be fully stable. I just wonder if there's anything else we can do to mitigate the implications - if this is the expected behaviour (memory footprint increase) I think it should be documented somewhere, although IMO this behaviour is not very trivial. |
This is creating an issue for us, since we instantiate contract objects on demand and get rid of them in long running operations. Why not using WeakMaps to make sure that you only update contracts that are still held by the user? or maybe providing some |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment, otherwise this issue will be closed in 7 days |
Not stale |
Watching this too |
I've discovered a workaround:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
Not stale, still an issue |
Not stale |
not stale, please fix |
Not stale! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
reopen |
This issue needs to be reopened. There is an open PR with a fix in #3866. |
Still an issue |
…ap class variable) to avoid web3.eth.Contract memory leak issue (web3/web3.js#3042), replace var with let/const where appropriate
This issue was crippling our servers due to needing to programatically interact with a lot of contracts. We have switched over to the |
This memory leak still going on, had to switch our project to |
Any update or workaround this? |
Did you read all the messages? |
The workaround seems to not be possible anymore now that I've also migrated to Effort & ResultsIt took about 12 hours to migrate a medium-complexity codebase from
|
Wow, this makes me really confident about the Ethereum ecosystem. |
Description
Expected behavior
Memory usage should stay low over time when instantiating
Contract
objects.Actual behavior
After investigating the heap there seems to be a closure leak which increases memory use over time until the process stops.
Steps to reproduce the behavior
You can run the following sample code with the gc exposed
You'll see the memory rapidly increasing:
This is the commit that introduced the issue 26a8775 (apologies for the direct "blame" it's just easier to direct to the actual code with the issue)
Removing the setProvider chaining solves the leak.
Error Logs
Gists
Versions
The text was updated successfully, but these errors were encountered: