Scala的GC问题

不会,因为绝大多数immutable变量用完即弃,不会存活到老年代,每一次的minor gc可以回收绝大多数内存。当然,频繁创造新对象会损失一部分执行效率,但是在大多数场景中,完全可以接受。
■网友
We spend a lot of time tuning garbage collection in production. The garbage collection concerns are largely similar to those of Java though idiomatic Scala code tends to generate more (short-lived) garbage than idiomatic Java code — a byproduct of the functional style. Hotspot’s generational garbage collection typically makes this a nonissue as short-lived garbage is effectively free in most circumstances.-- Effective Scala collection
【Scala的GC问题】 另题主说的常量, 应该是指immutable吧


    推荐阅读