Optimized memory management for class metadata in a JVM

A Java virtual machine (JVM) typically manages large amounts of class metadata (e.g. class descriptors, methods, byte codes) in main-memory. In this paper, we analyze the impact of metadata memory management on garbage collection costs in an industrial-strength JVM. We show that, for most applications in the latest DaCapo benchmark suite, the tracing of class metadata accounts for a significant part of full collection time. We propose a novel approach to metadata memory management based on metaspaces and on a linkset graph. Metaspaces store class metadata segregated by their class loader and keep an exact record of references from class metadata to the heap. The linkset graph summarizes what metaspaces reference others via resolved symbolic links. Metaspaces allow en masse reclamation of the storage allocated to classes defined by a class loader when this class loader becomes unreachable. The linkset graph eliminates the need to trace references between metadata to determine the liveness of classes and of the heap objects they refer to. This reduces the number of visited references in class metadata to less than 1% of the original amount and cuts down tracing time by up to 80%. Average full heap collection time improves by at least 35% for all but one of the Dacapo benchmarks, and by more than 70% for six of them. Metaspace-based management of class metadata also extends well to multi-tasking implementations of the JVM. It enables tasks to unload classes independently of other tasks.

[1]  Chandra Krintz,et al.  MTM2: Scalable Memory Management for Multi-tasking Managed Runtime Environments , 2008, ECOOP.

[2]  Grzegorz Czajkowski,et al.  Multitasking without compromise: a virtual machine evolution , 2001, SIGP.

[3]  D. B. Davis,et al.  Sun Microsystems Inc. , 1993 .

[4]  Kathryn S. McKinley,et al.  Immix: a mark-region garbage collector with space efficiency, fast collection, and mutator performance , 2008, PLDI '08.

[5]  Urs Hölzle,et al.  A Fast Write Barrier for Generational Garbage Collectors , 1993 .

[6]  Laurie J. Hendren,et al.  SableVM: A Research Framework for the Efficient Execution of Java Bytecode , 2001, Java Virtual Machine Research and Technology Symposium.

[7]  Amer Diwan,et al.  The DaCapo benchmarks: java benchmarking development and analysis , 2006, OOPSLA '06.

[8]  David Ungar Generation scavenging: a nondisruptive high performance storage reclamation algorithm , 1984 .

[9]  Kiyokuni Kawachiya,et al.  A study of Java's non-Java memory , 2010, OOPSLA.

[10]  Nathaniel Nystrom,et al.  Code Sharing among Virtual Machines , 2002, ECOOP.

[11]  Guy L. Steele,et al.  Java(TM) Language Specification, The (3rd Edition) (Java (Addison-Wesley)) , 2005 .

[12]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[13]  Elliot K. Kolodner,et al.  An algorithm for parallel incremental compaction , 2002, ISMM '02.

[14]  David M. Ungar,et al.  Generation Scavenging: A non-disruptive high performance storage reclamation algorithm , 1984, SDE 1.

[15]  Martin T. Vechev,et al.  Class Unloading with a Concurrent Garbage Collector in an Embedded Java VM , 2003, Embedded Systems and Applications.

[16]  Bernd Mathiske The maxine virtual machine and inspector , 2008, OOPSLA Companion.

[17]  Marcus Hirt,et al.  Oracle JRockit: The Definitive Guide , 2010 .

[18]  Stephen J. Fink,et al.  The Jalapeño virtual machine , 2000, IBM Syst. J..