We have developed an incremental compacting garbage collector for embedded Java systems. The collector divides the heap into equal sized pages and uses the segregated free lists for fast allocation. Collectors that have such a heap layout have a problem of fragmentation in allocating objects larger than the page size. We solve this problem by using the replication-based incremental compaction. The compactor evacuates all objects in one area, the evacuation area, of the heap, thereby creating a large chunk of free space. We developed an algorithm for choosing the evacuation area that effectively cures fragmentation. The compactor does not use any read-barriers. Instead, it uses a technique similar to the replication-based incremental copying collection. This needs forwarding pointers for all evacuated objects. Rather than introducing an extra field for each object, we use a hash table to store forwarding pointers. Evaluation of this garbage collector implemented in Sun's J2ME Java Virtual Machine showed that all the benchmarks used were able to run without memory starvation using the heap sizes of only 151%-286% of the maximum amount of live data plus 8 KB of the hash table. Experiments on a desktop computer, though it is not a platform for embedded systems, showed that the maximum pause time was shorter than 200 μs, which was comparable to that of our implementation of the snapshot-at-the-beginning collector without compaction. On an ARM processor, the runtime overhead was 1%-16% with 8.0% on average compared to the mark-sweep collector.
Read full abstract