-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
builtin: fix map.clear() not resetting map's metas and keys blocks (fix #22139) #22140
builtin: fix map.clear() not resetting map's metas and keys blocks (fix #22139) #22140
Conversation
…se a single unsafe{} block for clarity
Hi @spytheman 😄 I think you also have to clear/free the memory of the denseArray. I think that right now it will just leak. |
@ka-weihe thanks for reviewing. I think, that the explicit goal of that .clear() method, rather than just Is there a mechanism, where the old blocks would just leak (rather than being reused), and new ones will be allocated instead, when the user does this for example: mut m := map[int]int{}
m[123] = 456
m[789] = 321
m.clear()
m[1] = 10
m[2] = 20 |
Hmm, after looking at the code again, I think it might actually be fine, but it would be interesting to run it in a loop and see if the memory usage keeps increasing. I don't think it will, but it's a good test. |
Yes, the You can always do |
I've added I've tested with these commands on my latest commit, if someone else wants to check: (you will need the latest commit 63a51ff) |
Fix #22139 .