-
Notifications
You must be signed in to change notification settings - Fork 21
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
Scala 2.12 map.keySet leaks reference to map #11727
Comments
@fanf it looks that |
I think it makes sense that
|
Yes, it would be very appreciated to make obvious the fact that it's a view and not a new object, AND what is the best (most efficient) method to get a fresh, independant |
(I knew about |
|
@SethTisue most likely from my user point of view, but I don't know if there's better way :) |
Both |
@scala/collections is 2.13 also affected? (if it's 2.12-only we should close the ticket) |
2.13 is similarly a view onto the enclosing
The 2.13 nomenclature dictates that Agree that a tweak to the Scaladoc is deemed advisable. |
Today's complaint in chat was that Generally,
|
heh, I hit this problem this week. The side effect was that I thought I'd discovered a new way to add 4 bit numbers together that used a lot less diodes and transistors than the usual encoding. Suffice to say, my excitement has been suitably squashed upon discovery that I was accidentally deduplicating before applying my cost function... le sigh. |
To quote Jesus from "The Chosen" tv show, "In this world, bones will break, and hearts will break." He goes on to say that in Scala 4, matters are much improved. |
Hello, we discovered with prod pain and crashes that
Map.keySet
leaks a reference to the Map object so that it is not GC'ed and leaks memory - huge memory if objects in the map are big and you wanted to only return light identifiers to them.It can be seen for ex here: https://gist.github.com/fanf/ff39065f7f9738467e40929ad7490da1
Is this known/wanted and I'm just 13 years late in that knowledge, or is it a bug (at least a bad documentation)?
The problem is likely the references to self in
DefaultKeySet
(contains
,size
...) https://github.com/scala/scala/blob/2.12.x/src/library/scala/collection/MapLike.scala#L176The text was updated successfully, but these errors were encountered: