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

trie: fixes two issues in trie iterator #24539

Merged
merged 4 commits into from
Mar 15, 2022
Merged

Conversation

rjl493456442
Copy link
Member

This PR fixes two issues in iterator:

  • Fix the memory leak in iterator.

In trie iterator each resolved trie node will be wrapped with a struct and the corresponding pointer will be saved in the stack based slice. Whenever the node is visited, the struct is poped from stack. However this struct point should be explicitly set to nil in order to garbage collect the underlying struct.

  • Fix the empty trie iterator

The empty trie shouldn't be iterated out any values.

In trie iterator a batch of live nodes will be tracked and be poped
when it's iterated. However the poped node state should be explictly
set to nil in order to be garbage collected.
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ligi ligi added the pr:merge label Mar 15, 2022
@fjl fjl merged commit fb2ae8e into ethereum:master Mar 15, 2022
@fjl fjl added this to the 1.10.17 milestone Mar 15, 2022
sidhujag pushed a commit to syscoin/go-ethereum that referenced this pull request Mar 16, 2022
* trie: fix memory leak in trie iterator

In the trie iterator, live nodes are tracked in a stack while iterating.
Popped node states should be explictly set to nil in order to get
garbage-collected.

* trie: fix empty trie iterator
JacekGlen pushed a commit to JacekGlen/go-ethereum that referenced this pull request May 26, 2022
* trie: fix memory leak in trie iterator

In the trie iterator, live nodes are tracked in a stack while iterating.
Popped node states should be explictly set to nil in order to get
garbage-collected.

* trie: fix empty trie iterator
maoueh pushed a commit to streamingfast/go-ethereum that referenced this pull request Sep 30, 2022
* trie: fix memory leak in trie iterator

In the trie iterator, live nodes are tracked in a stack while iterating.
Popped node states should be explictly set to nil in order to get
garbage-collected.

* trie: fix empty trie iterator
cp-wjhan pushed a commit to cp-yoonjin/go-wemix that referenced this pull request Nov 16, 2022
* trie: fix memory leak in trie iterator

In the trie iterator, live nodes are tracked in a stack while iterating.
Popped node states should be explictly set to nil in order to get
garbage-collected.

* trie: fix empty trie iterator
HAOYUatHZ pushed a commit to scroll-tech/go-ethereum that referenced this pull request May 28, 2024
* trie: fix memory leak in trie iterator

In the trie iterator, live nodes are tracked in a stack while iterating.
Popped node states should be explictly set to nil in order to get
garbage-collected.

* trie: fix empty trie iterator
HAOYUatHZ added a commit to scroll-tech/go-ethereum that referenced this pull request May 28, 2024
* trie: fix two issues in trie iterator (ethereum#24539)

* trie: fix memory leak in trie iterator

In the trie iterator, live nodes are tracked in a stack while iterating.
Popped node states should be explictly set to nil in order to get
garbage-collected.

* trie: fix empty trie iterator

* fix lint

* chore: auto version bump [bot]

---------

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
Co-authored-by: HAOYUatHZ <HAOYUatHZ@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants