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

Ensure slices are zeroed #3407

Merged
merged 2 commits into from
Sep 20, 2024
Merged

Ensure slices are zeroed #3407

merged 2 commits into from
Sep 20, 2024

Conversation

StephenButtolph
Copy link
Contributor

@StephenButtolph StephenButtolph commented Sep 20, 2024

Why this should be merged

Golang can only GC the memory if there are no remaining references to it. Because it's possible to re-extend slices, the memory doesn't get GCed.

How this works

Uses clear (and deletes the ZeroSlice helper).

How this was tested

N/A

@StephenButtolph StephenButtolph marked this pull request as ready for review September 20, 2024 19:13
@StephenButtolph StephenButtolph self-assigned this Sep 20, 2024
@StephenButtolph StephenButtolph added the cleanup Code quality improvement label Sep 20, 2024
@StephenButtolph StephenButtolph added this to the v1.11.12 milestone Sep 20, 2024
s[i] = *new(T)
}
func Zero[T any]() (_ T) {
return
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No clue why we had this and it was never used... weird

@StephenButtolph StephenButtolph added this pull request to the merge queue Sep 20, 2024
Merged via the queue into master with commit 75fc684 Sep 20, 2024
22 checks passed
@StephenButtolph StephenButtolph deleted the ensure-slices-are-zeroed branch September 20, 2024 19:38
Copy link

@philipjonsen philipjonsen 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. some with more knowledge about avax should review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code quality improvement
Projects
Status: Done ✅
Development

Successfully merging this pull request may close these issues.

5 participants