skip to main content
research-article

new Scala() instance of Java: a comparison of the memory behaviour of Java and Scala programs

Published:15 June 2012Publication History
Skip Abstract Section

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.

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. J. Bloch. Effective Java. Sun Microsystems, Inc., 2nd edition, 2008.Google ScholarGoogle Scholar
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. I. Dragos. Compiling Scala for performance. PhD thesis, École polytechnique fédérale de Lausanne, 2010.Google ScholarGoogle Scholar
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. J. Gosling, B. Joy, G. Steele, and G. Bracha. Java Language Specification. Addison-Wesley Longman Publishing Co., Inc., 3rd edition, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. T. Lindholm and F. Yellin. Java Virtual Machine Specification. Addison-Wesley Longman Publishing Co., Inc., 2nd edition, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. Odersky, L. Spoon, and B. Venners. Programming in Scala. Artima Press, 2nd edition, 2010.Google ScholarGoogle Scholar
  21. I. Pechtchanski and V. Sarkar. Immutability specification and its applications. In Proceedings of the 2002 joint ACM-ISCOPE Conference on Java Grande, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. new Scala() instance of Java: a comparison of the memory behaviour of Java and Scala programs

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 47, Issue 11
          ISMM '12
          November 2012
          136 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2426642
          Issue’s Table of Contents
          • cover image ACM Conferences
            ISMM '12: Proceedings of the 2012 international symposium on Memory Management
            June 2012
            152 pages
            ISBN:9781450313506
            DOI:10.1145/2258996

          Copyright © 2012 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 15 June 2012

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!