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 connmanager #1576

Merged
merged 1 commit into from
Jan 12, 2023
Merged

Fix memory leak in connmanager #1576

merged 1 commit into from
Jan 12, 2023

Conversation

hxw
Copy link
Contributor

@hxw hxw commented May 14, 2020

In the case of an error the connection struct is never deleted from the pending hash map.

In some testing I observed leaks of 3MB in an hour

The problem stem from the fact that the handleFailedConn does not reuse the connect but allocate a new one

@jcvernaleo
Copy link
Member

@hxw Sorry I missed this one. Looks good. Is there any chance you could rebase this so the CI can run properly and squash to one commit? I think that is all it will need to be good to go.

Copy link
Member

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

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

Needs rebase and squash but otherwise looks good.

@hxw
Copy link
Contributor Author

hxw commented Jan 11, 2023

Sorry I totally forgot about this, until I rebuild my program last week and I stated getting leaks over the last few days, only just realised what the problem was. I have merged my branch with the current master and will test first. I will then rebase, squash etc. when I have done some testing.

fix memory leak in connmanager caused by:

* pending entries are not removed on error
* new connection always allocates new struct
* capture id value for callback

Fix by calling Remove in both handleFailedConn callbacks to delete the
item from the pending hash map

Signed-off-by: Christopher Hall <[email protected]>
@coveralls
Copy link

Pull Request Test Coverage Report for Build 3889135262

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • 15 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.03%) to 55.151%

Files with Coverage Reduction New Missed Lines %
btcutil/gcs/gcs.go 1 81.25%
mempool/mempool.go 1 66.75%
peer/peer.go 13 73.2%
Totals Coverage Status
Change from base Build 3851947300: -0.03%
Covered Lines: 26560
Relevant Lines: 48159

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 3889598567

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • 17 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.03%) to 55.144%

Files with Coverage Reduction New Missed Lines %
btcutil/gcs/gcs.go 1 81.25%
mempool/mempool.go 1 66.75%
txscript/taproot.go 2 95.93%
peer/peer.go 13 73.2%
Totals Coverage Status
Change from base Build 3851947300: -0.03%
Covered Lines: 26557
Relevant Lines: 48159

💛 - Coveralls

@hxw hxw requested a review from jcvernaleo January 12, 2023 09:56
Copy link
Member

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

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

Looks good now!

OK

@jcvernaleo jcvernaleo merged commit 1d77730 into btcsuite:master Jan 12, 2023
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

Successfully merging this pull request may close these issues.

3 participants