Managed runtime environments (MREs) employ garbage collection (GC) for automatic memory management and safety. However, GC induces pressure on the virtual memory (VM) manager at the operating system level, since it may touch pages that are not related to the working set of the application. Paging due to GC can introduce significant performance overhead, even when the working set of the application fits into physical memory.
In this paper, we present a feedback-directed heap resizing mechanism to avoid GC-induced paging. Our MRE employs information from the operating system (OS) to guide decisions about when to grow and shrink the heap dynamically. By doing so, we avoid costly GCs when there is physical memory available and trade off paging for garbage collection when memory is constrained -- since the cost of many GCs is significantly less than swapping a page of memory to/from disk. Our MRE resizing system is novel in that it is very simple, uses allocation stall events during GC alone to trigger resizing, and requires no user participation or extensive OS modification.
We implement our scheme for paging avoidance in the freely available and popular JikesRVM MRE, and Linux operating system. We describe the design and implementation of the system and evaluate it using a number of common Java benchmarks. Our results indicate that our system significantly improves performance when real memory is restricted and enables similar to, or better performance than, the best-performing JikesRVM GC system when memory is unconstrained.