-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
5704 memory leak in web3.eth.contract #5792
Conversation
Deploying with
|
Latest commit: |
c6026b8
|
Status: | ✅ Deploy successful! |
Preview URL: | https://649e9e5c.web3-js-docs.pages.dev |
Branch Preview URL: | https://ok-5704-memory-leak-in-web3-.web3-js-docs.pages.dev |
@@ -91,16 +88,6 @@ export class Web3 extends Web3Context<EthExecutionAPI> { | |||
} else { | |||
super(jsonInterface, self.getContextObject()); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also update change log for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, except a minor change log work.
CHANGELOG.md
Outdated
|
||
##### Removed | ||
|
||
- Private static `_contracts:Contract[]` and static `setProvider` function was removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add PR/Issue number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Description
Fixes #5704
So the problem was a new
SubscriptionManager
which was created every time when making a new instance of the Contract class because, by default, web3 didn't create theregisteredSubscriptions
object. So I've added the object by default. And now it always reuses the sameSubscriptionManager
in the contract class.Also, I've removed the array of contracts in the web3 package. Because we don't need it. When we set the provider in one of the contracts or in web3, it affects all instances.
After these changes memory leak disappears.
Type of change
Checklist for 4.x:
yarn
successfullyyarn lint
successfullyyarn build:web
successfullyyarn test:unit
successfullyyarn test:integration
successfullycompile:contracts
successfullyCHANGELOG.md
file in the packages I have edited.