Tuesday, November 19, 2013

Sickness & Taking Out The Garbage Scientifically


As the pills took hold of my internal (bodily) Garbage Collector and tuned it to more efficiently remove unneeded and unwanted objects, TheHackerCIO's thought naturally turned to his beloved JVM and it's own GC algorithms. For those more managerial, Garbage collection is part of the major advantage of Java over the old C and C++ environments. It allows the programmer to depend upon the environment to manage memory, rather than having to explicitly perform this in code.

There are two major advantages to using GCs. Memory management takes up a huge amount of development time, estimated by some at 40 to 60%! And secondly, if you mess up, it's easy to get a memory leak. Those are what cause your old windows box to hang on you, back in the day. The memory of your machine kept getting used up and never was released, so eventually there was no more memory left. So you were "hosed." That's a technical term. :-)

GC is an important issue in todays world, and I had been unsatisfied by the Java Performance book our Geeky Book Club read recently, most specifically by it's treatment of the GC algorithms. It seemed to be poorly organized from the standpoint of fundamental types of GC. Instead it plunged right in to the present state of GC available.

I was confirmed in this opinion by hearing a wonderful talk by Azul, who make a for-purchase JVM built around the idea of a "pauseless GC." In other words, in most GCs, when you collect the garbage, all work must stop. This is called "Stop the World," because all threads doing application work are stopped while the GC "pauses," collects the garbage, reclaims memory for new use, and then restarts the application. If the heap is big, a pause could be long. Maybe seconds. Maybe even 4-5 seconds? Now your talking availability problems!

Consequently, the GC needs to be understood. And tuned.

The talk by AzulSystems was far better organized. It cut through euphemism, defined and organized the presentation around fundamental GC types, then explored the currently available GCs and how they fit into those categories in terms of their performance characteristics. And the CTO mentioned that the bible for them was this book by Jones (image below), called The Garbage Collection Handbook:



So naturally, I ordered a copy.

The book is wonderful. I'm only on chapter two, but even if difficult/demanding, since it's well organized and doesn't leave dangling questions, it's a far better resource to read first, before attempting the Java Performance book, already reviewed here.

Plus, this is the absolute latest update on GC algorithms and technology! Further details will follow.

I Remain Thinking of Garbage,

lol,

TheHackerCIO