Back to overview

new Scala() instance of Java: A Comparison of the Memory Behaviour of Java and Scala programs

Type of publication Peer-reviewed
Publikationsform Original article (peer-reviewed)
Publication date 2012
Author Sewe Andreas, Mezini Mira, Sarimbekov Aibek, Ansaloni Danilo, Binder Walter, Ricci Nathan, Guyer Samuel Z.,
Project FAN: Foundations of dynamic program ANalysis
Show all

Original article (peer-reviewed)

Journal ACM SIGPLAN Notices
Volume (Issue) 47(11)
Page(s) 97 - 108
Title of proceedings ACM SIGPLAN Notices
DOI 10.1145/2426642.2259010


While often designed with a single language in mind, managed runtimes like the Java virtual machine (JVM) have become the target of not one but many languages, all of which benefit from the runtime's services. One of these services is automatic memory management. In this paper, we compare and contrast the memory behaviour of programs written in Java and Scala, respectively, two languages which both target the same platform: the JVM. We both analyze core object demographics like object lifetimes as well as secondary properties of objects like their associated monitors and identity hash-codes. We find that objects in Scala programs have lower survival rates and higher rates of immutability, which is only partly explained by the memory behaviour of objects representing closures or boxed primitives. Other metrics vary more by benchmark than language.