Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

prefetcher: avoid mem leaks by not storing block in request #1988

Merged
merged 3 commits into from
Dec 20, 2018

Conversation

strib
Copy link
Contributor

@strib strib commented Dec 20, 2018

We don't actually use the contents of the block in the request; we only use it to generate a new block. So just store the function for generating the new block instead, to be more explicit.

Also, don't pass the same block used to make that function to the Request() function, which fills in the block. I suspect that was a memory leak.

Issue: #1958

All we need it for is to generate a new block, so just keep the
function for making the new block instead.

Issue: #1958
@strib strib requested a review from a team December 20, 2018 18:13
Copy link
Contributor

@jzila jzila left a comment

Choose a reason for hiding this comment

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

love it!

So the prefetcher can get a new block function without holding a
reference to the block that supplied it.

Issue: #1958
@strib
Copy link
Contributor Author

strib commented Dec 20, 2018

@jzila i changed this around a bit because I was worried that keeping around b.NewEmpty would keep a reference to b around as well. So now there's a b.NewEmptier() function which just returns a static function that doesn't need to keep the old block around.

@strib strib merged commit f7583d6 into master Dec 20, 2018
@strib strib deleted the strib/fix-prefetch-mem-leak-2 branch December 20, 2018 21:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants