While many object-oriented languages impose space overhead of only one word per object to support features like virtual method dispatch, Java's richer functionality has led to implementations that require two or three header words per object. This space overhead increases memory usage and attendant garbage collection costs, reduces cache locality, and constrains programmers who might naturally solve a problem by using large numbers of small objects.
In this paper, we show that with careful engineering, a high performance virtual machine can instantiate most Java objects with only a single-word object header. The single header word provides fast access to the virtual method table, allowing for quick method invocation. The implementation represents other per-object data (lock state, hash code, and garbage collection flags) using heuristic compression techniques. The heuristic retains two-word headers, containing thin lock state, only for objects that have synchronized methods.
We describe the implementation of various object models in the IBM Jikes Research Virtual Machine, by introducing a pluggable object model abstraction into the virtual machine implementation. We compare the original Jikes RVM object model with three different object models with single-word headers. Experimental results show that the object header compression techniques give an average space savings of 7%, with savings of up to 21%. Compared to the original Jikes RVM object model, the compressed space-encodings result in application speedups ranging from -1.5%$ to +2.2%. Performance on synthetic micro-benchmarks ranges from +23% due to benefits from reduced object size, to -12% on a stress test of virtual method invocation.