-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
scala/scala
#10544Description
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#L176