Hot-Swapping Between a Mark&Sweep and a Mark&Compact Garbage Collector in a Generational Environment

This paper describes a novel method for dynamically switching between a Mark&Compact (M&C) and a Mark&Sweep (M&S) garbage collector in the generational memory system of a high performance Java virtual machine. A M&C collector reclaims space by sliding all live objects towards the beginning of the heap. A M&S collector de-allocates garbage objects in-place. In this paper, both algorithms are assumed to operate over the old generation of a generational memory system and on their own provide different trade-offs to the application that uses them: faster old collections but with slower young collections and the possibility of fragmentation (M&S) or slower old collections but with faster young collections and the guarantee to eliminate fragmentation (M&C). We propose Hot-Swapping, a technique for dynamically switching between these two algorithms, to attempt to achieve the "best of both worlds". Its introduction to the memory system of the virtual machine imposed minimal changes to the existing implementations of M&C and M&S and virtually no extra performance overhead. Experimental results, presented in the paper, show that this hybrid scheme can either outperform both algorithms, or is very close to the faster of the two (whether this is M&S or M&C), while never being the slowest.

[1]  Andrew W. Appel,et al.  Garbage Collection can be Faster than Stack Allocation , 1987, Inf. Process. Lett..

[2]  Paul R. Wilson,et al.  Dynamic Storage Allocation: A Survey and Critical Review , 1995, IWMM.

[3]  David Detlefs,et al.  A generational mostly-concurrent garbage collector , 2000, ISMM '00.

[4]  Hans-Juergen Boehm,et al.  Garbage collection in an uncooperative environment , 1988, Softw. Pract. Exp..

[5]  Joel F. Bartlett,et al.  Mostly-Copying Garbage Collection Picks Up Generations and C++ , 1999 .

[6]  David Detlefs,et al.  Inlining of Virtual Methods , 1999, ECOOP.

[7]  Paul R. Wilson,et al.  Uniprocessor Garbage Collection Techniques , 1992, IWMM.

[8]  Chris J. Cheney A nonrecursive list compacting algorithm , 1970, Commun. ACM.

[9]  Paul R. Wilson,et al.  The memory fragmentation problem: solved? , 1998, ISMM '98.

[10]  Henry Lieberman,et al.  A real-time garbage collector based on the lifetimes of objects , 1983, CACM.

[11]  H. B. M. Jonkers,et al.  A Fast Garbage Compaction Algorithm , 1979, Inf. Process. Lett..

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

[13]  Andrew W. Appel,et al.  Simple generational garbage collection and fast allocation , 1989, Softw. Pract. Exp..

[14]  Bernard Lang,et al.  Incremental incrementally compacting garbage collection , 1987, PLDI.

[15]  Alex Garthwaite,et al.  The GC Interface in the EVM 1 , 1998 .

[16]  Ole Agesen GC Points in a Threaded Environment , 1998 .

[17]  Patrick M. Sansom Combining Single-Space and Two-Space Compacting Garbage Collectors , 1991, Functional Programming.

[18]  Rafael Dueire Lins,et al.  Garbage collection: algorithms for automatic dynamic memory management , 1996 .

[19]  Joel F. Bartlett,et al.  Compacting garbage collection with ambiguous roots , 1988, LIPO.

[20]  Y. S. Ramakrishna,et al.  An efficient meta-lock for implementing ubiquitous synchronization , 1999, OOPSLA '99.

[21]  Andrew W. Appel,et al.  Cache performance of fast-allocating programs , 1995, FPCA '95.

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