Abstract
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.
- O. Agesen, D. Detlefs, A. Garthwaite, R. Knippel, Y. Ramakrishna, and D. White. An efficient meta-lock for implementing ubiquitous synchronization. Technical report, Sun Microsystems, Inc., 1999. Google Scholar
Digital Library
- D. Bacon, S. Fink, and D. Grove. Space- and time-efficient implementation of the Java object model. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP), 2006. Google Scholar
Digital Library
- D. F. Bacon, R. Konuru, C. Murthy, and M. Serrano. Thin locks: featherweight synchronization for Java. In Proceedings of the Conference on Programming Language Design and Implementation (PLDI), 1998. Google Scholar
Digital Library
- VanDrunen, von Dincklage, and Wiedermann}Blackburn:2006:dacapoS. M. Blackburn, R. Garner, C. Hoffmann, A. M. Khang, K. S. McKinley, R. Bentzur, A. Diwan, D. Feinberg, D. Frampton, S. Z. Guyer, M. Hirzel, A. Hosking, M. Jump, H. Lee, J. E. B. Moss, B. Moss, A. Phansalkar, D. Stefanović, T. VanDrunen, D. von Dincklage, and B. Wiedermann. The DaCapo benchmarks: Java benchmarking development and analysis. In Proceedings of the 21st Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2006. Google Scholar
Digital Library
- J. Bloch. Effective Java. Sun Microsystems, Inc., 2nd edition, 2008.Google Scholar
- S. Dieckmann and U. Hölzle. A study of the allocation behavior of the SPECjvm98 Java benchmarks. In Proceedings of the European Conference on Object-Oriented Programming (ECCOP), 1999. Google Scholar
Digital Library
- I. Dragos. Compiling Scala for performance. PhD thesis, École polytechnique fédérale de Lausanne, 2010.Google Scholar
- B. Dufour, K. Driesen, L. Hendren, and C. Verbrugge. Dynamic metrics for Java. In Proceedings of the 18th Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2003. Google Scholar
Digital Library
- B. Dufour, C. Goard, L. Hendren, O. de Moor, G. Sittampalam, and C. Verbrugge. Measuring the dynamic behaviour of AspectJ programs. In Proceedings of the 19th Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2004. Google Scholar
Digital Library
- B. Dufour, B. G. Ryder, and G. Sevitsky. A scalable technique for characterizing the usage of temporaries in framework-intensive Java applications. In Proceedings of the 16th International Symposium on Foundations of Software Engineering (FSE), 2008. Google Scholar
Digital Library
- B. Goetz, T. Peierls, J. Bloch, J. Bowbeer, D. Holmes, and D. Lea. Java Concurrency in Practice. Addison-Wesley Longman Publishing Co., Inc., 2006. Google Scholar
Digital Library
- J. Gosling, B. Joy, G. Steele, and G. Bracha. Java Language Specification. Addison-Wesley Longman Publishing Co., Inc., 3rd edition, 2005. Google Scholar
Digital Library
- C. Haack and E. Poll. Type-based object immutability with flexible initialization. In Proceedings of the European Conference on Object-Oriented Programming (ECCOP), 2009. Google Scholar
Digital Library
- Hertz:2002:merlinM. Hertz, S. M. Blackburn, J. E. B. Moss, K. S. McKinley, and D. Stefanović. Generating object lifetime traces with Merlin. ACM Transactions on Programming Languages and Systems, 28 (3): 476--516, 2006. Google Scholar
Digital Library
- I. Jibaja, S. Blackburn, M. Haghighat, and K. McKinley. Deferred gratification: Engineering for high performance garbage collection from the get go. In Proceedings of the Workshop on Memory Systems Performance and Correctness (MSPC), 2011. Google Scholar
Digital Library
- R. E. Jones and C. Ryder. A study of Java object demographics. In Proceedings of the 7th International Symposium on Memory management (ISMM), 2008. Google Scholar
Digital Library
- J.-S. Kim and Y. Hsu. Memory system behavior of Java programs: methodology and analysis. In Proceedings of the 2000 ACM SIGMETRICS Conference on Measurement and Modeling of Computer Systems (SIGMETRICS), 2000. Google Scholar
Digital Library
- T. Lindholm and F. Yellin. Java Virtual Machine Specification. Addison-Wesley Longman Publishing Co., Inc., 2nd edition, 1999. Google Scholar
Digital Library
- L. Marek, A. Villazón, Y. Zheng, D. Ansaloni, W. Binder, and Z. Qi. DiSL: a domain-specific language for bytecode instrumentation. In Proceedings of the 11th International Conference on Aspect-Oriented Software Development (AOSD), 2012. Google Scholar
Digital Library
- M. Odersky, L. Spoon, and B. Venners. Programming in Scala. Artima Press, 2nd edition, 2010.Google Scholar
- I. Pechtchanski and V. Sarkar. Immutability specification and its applications. In Proceedings of the 2002 joint ACM-ISCOPE Conference on Java Grande, 2002. Google Scholar
Digital Library
- F. Pizlo, D. Frampton, and A. L. Hosking. Fine-grained adaptive biased locking. In Proceedings of the 9th International Conference on Principles and Practice of Programming in Java (PPPJ), 2011. Google Scholar
Digital Library
- S. Porat, M. Biberstein, L. Koved, and B. Mendelson. Automatic detection of immutable fields in Java. In Proceedings of the 2000 Conference of the Centre for Advanced Studies on Collaborative Research (CASCON), 2000. Google Scholar
Digital Library
- T. Printezis and R. Jones. GCspy: an adaptable heap visualisation framework. In Proceedings of the 17th Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2002. Google Scholar
Digital Library
- N. P. Ricci, S. Z. Guyer, and J. E. B. Moss. Elephant Tracks: generating program traces with object death records. In Proceedings of the 9th International Conference on Principles and Practice of Programming in Java (PPPJ), 2011. Google Scholar
Digital Library
- K. Russell and D. Detlefs. Eliminating synchronization-related atomic operations with biased locking and bulk rebiasing. In Proceedings of the 21st Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2006. Google Scholar
Digital Library
- A. Sewe, M. Mezini, A. Sarimbekov, and W. Binder. Da Capo con Scala: Design and analysis of a Scala benchmark suite for the Java Virtual Machine. In Proceedings of the 26th Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2011. Google Scholar
Digital Library
- A. Shankar, M. Arnold, and R. Bodik. Jolt: lightweight dynamic analysis and removal of object churn. In Proceedings of the 23rd Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPLSA), 2008. Google Scholar
Digital Library
- X. Yang, S. M. Blackburn, D. Frampton, J. B. Sartor, and K. S. McKinley. Why nothing matters: the impact of zeroing. In Proceedings of the 26th Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2011. Google Scholar
Digital Library
Index Terms
new Scala() instance of Java: a comparison of the memory behaviour of Java and Scala programs
Recommendations
new Scala() instance of Java: a comparison of the memory behaviour of Java and Scala programs
ISMM '12: Proceedings of the 2012 international symposium on Memory ManagementWhile 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 ...
Evaluating the Java Native Interface JNI: Leveraging Existing Native Code, Libraries and Threads to a Running Java Virtual Machine
This article aims to explore JNI features and to discover fundamental operations of the Java programming language, such as arrays, objects, classes, threads and exception handling, and to illustrate these by using various algorithms and code samples. ...
Da capo con scala: design and analysis of a scala benchmark suite for the java virtual machine
OOPSLA '11: Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applicationsOriginally conceived as the target platform for Java alone, the Java Virtual Machine (JVM) has since been targeted by other languages, one of which is Scala. This trend, however, is not yet reflected by the benchmark suites commonly used in JVM ...







Comments