First of all: the actual release of unused memory occurs whenever the GC JVM considers it necessary. Thus, scalac cannot do this.
, scalac, , , .
val huge: HugeObjectType
val derivative1 = huge.map(_.x)
huge = null // inserted by scalac
val derivative2 = derivative1.groupBy(....)
derivative1 = null // inserted by scalac
scala -Internals, , Hotspot JVM . . scalac hacker Grzegorz Kossakowski .
, JVM JIT-, JIT- . , , JVM .
.
, , apache, , , . , .
. - defs.
def huge: HugeObjectType
def derivative1 = huge.map(_.x)
def derivative2 = derivative1.groupBy(....)
val result = derivative2.<some other transform>
, - ! , map filter, , . ! , groupBy, . .