Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
runtime: maps do not shrink after elements removal (delete) #20135
What version of Go are you using (
I'm surprised there isn't a dup of this already in the issue tracker.
Yes, maps that shrink permanently currently never get cleaned up after. As usual, the implementation challenge is with iterators.
Maps that shrink and grow repeatedly used to also cause leaks. That was #16070, fixed by CL 25049. I remember hoping when I started on that CL that the same mechanism would be useful for shrinking maps as well, but deciding it wouldn't. Sadly, I no longer remember why. If anyone wants to investigate this issue, I'd start by looking at that CL and thinking about whether that approach could be extended to shrinking maps.
The only available workaround is to make a new map and copy in elements from the old.