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

fix: memory leak in Import #773

Merged
merged 5 commits into from
May 19, 2023
Merged

fix: memory leak in Import #773

merged 5 commits into from
May 19, 2023

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented May 19, 2023

Closes: #772

don't need to reference the children, which recursively retain the whole subtree in memory.

don't need to reference the children, which recursively retain the whole subtree in memory.
CHANGELOG.md Outdated Show resolved Hide resolved
yihuang added a commit to yihuang/iavl that referenced this pull request May 19, 2023
don't reference the children, which recursively retain the whole subtree in memory.
@tac0turtle tac0turtle merged commit 6e98074 into cosmos:master May 19, 2023
@@ -55,7 +55,7 @@ var (
metadataKeyFormat = keyformat.NewKeyFormat('m', 0) // m<keystring>
)

var errInvalidFastStorageVersion = fmt.Errorf("Fast storage version must be in the format <storage version>%s<latest fast cache version>", fastStorageVersionDelimiter)
var errInvalidFastStorageVersion = fmt.Errorf("fast storage version must be in the format <storage version>%s<latest fast cache version>", fastStorageVersionDelimiter)

Choose a reason for hiding this comment

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

Just curious why this change

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There a lint warns about the leading upper case in string

Comment on lines +136 to +143
leftNode := i.stack[stackSize-2]
rightNode := i.stack[stackSize-1]

node.leftNode = leftNode
node.rightNode = rightNode
node.leftNodeKey = leftNode.nodeKey
node.rightNodeKey = rightNode.nodeKey
node.size = leftNode.size + rightNode.size

Choose a reason for hiding this comment

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

It seems to me that you moved leftNode and rightNode to vars and re-used, but isn't that the same has node.leftNode and node.rightNode or does GO have an issue with using the object?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it's equivalent, it's just I think it makes code shorter this way, because the node.leftNode will be repeated many times

Comment on lines +153 to +157
// remove the recursive references to avoid memory leak
leftNode.leftNode = nil
leftNode.rightNode = nil
rightNode.leftNode = nil
rightNode.rightNode = nil

Choose a reason for hiding this comment

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

Guess this is the actual fix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes

tac0turtle pushed a commit that referenced this pull request May 19, 2023
@tac0turtle
Copy link
Member

tac0turtle commented May 19, 2023

removing what comments? i didnt touch anything other than merge. If i deleted a comment it would say a comments were deleted, not sure what youre talking about

@joshlopes
Copy link

@tac0turtle the comments are back, probably a hiccup within GH API, basically I left the comments above and you merged the PR - I saw the event merged and the comments were no were so I assumed you had deleted them to merge/don't stale.

Apologies! 🙇

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.

Memory leak during State Sync
3 participants