Google I/O shook things up a bit last week - ART is finally for sure (or more for sure, I guess), and now we've seen some cool new developer tools - but one significant aspect of ART that didn't get covered is garbage collection. According to the updated ART documentation, a compacting garbage collector is coming to AOSP.
If you're not familiar with compacting garbage collectors, this is a pretty cool development. Mark Murphy on The CommonsBlog has covered the development in detail, and sums it up succinctly:
With a compacting garbage collector, the long-lived objects get slid around in memory, to allow the freed-up blocks of memory to be coalesced. The net is that all free heap space should be available as one contiguous block, eligible for allocation.
Dalvik's garbage collection, on the other hand, is non-compacting. That means that when you free up space in memory, it doesn't get reorganized into usable blocks - it stays where it is.
That's a promising development for Android developers. As Murphy notes, if compacting garbage collection is coming to ART and ART is coming to Android 5.0, we're looking at a future with much more reasonable memory management in Android by default.
Or, for a simpler conclusion from Murphy:
I, for one, welcome our new ARTist overlords.