Architecture #15678
closed
Remove Map#mapValues because of memory not freed
Added by François ARMAND almost 5 years ago.
Updated almost 4 years ago.
Category:
Performance and scalability
Description
Map#mapValues
is only a view on the original map. The original values are still referenced and the original map never freed.
For this one, the leak is really tricky, because in that code:
def main(args: Array[String]): Unit = {
def res() = {
printMem("in res 0")
val m = Map(1 -> bigArray, 2 -> bigArray, 3 -> bigArray)
val m2 = m.mapValues(_ => smallArray)
printMem("in res 1")
m2
}
printMem("start")
val map1 = res()
printMem("end")
}
m
is still referenced during all the life of m2
and so map1
. But from map1
point of view, it's a simple, small map.
- Tracker changed from Bug to Architecture
- Priority deleted (
0)
- Target version changed from 5.0.13 to 5.0.14
- Target version changed from 5.0.14 to 5.0.15
- Target version changed from 5.0.15 to 5.0.16
What would be the prefered way ? map{ case (a,b) => b.doSomething} ?
- Target version changed from 5.0.16 to 5.0.17
- Target version changed from 5.0.17 to 5.0.18
- Parent task deleted (
#15675)
- Related to Bug #15675: Leak in Cache of Node Compliance and NodeInfo and perfs improvement added
- Target version changed from 5.0.18 to 6.2.0~beta1
- Target version changed from 6.2.0~beta1 to 6.2.0~rc1
- Status changed from New to Rejected
It's more complicated than that, and @ncharles already did a lot of work on that. Closing this one, a more details, case by case analysis need to be done.
Also available in: Atom
PDF