A New Age of JVM Garbage Collectors

Welcome to this blog again; throughout the past blogs we have discussed a lot of topics focused on Lisp, Clojure and computer science in general, but today is the turn of one of the greatest commodities in the contemporaneous area, garbage collection, this feature literally changed and simplified the programming process. So, in this blog I'm going to summaries and give my humble opinion on the topics discussed in Alexander Yakushev talk, A new age of JVM garbage collectors.

So, for anyone not related to programming or familiarize with garbage collection, let me start with an example:

You have two strings, "Hello" and "World",  these strings are saved in an address in memory, meaning they are taking a space in RAM; now you want to concatenate this strings, so you end up with a string containing "Hello World". Now, you don't need the previews strings, but they are still taking space in the finite and precious memory, and if this space is not free, it will be wasted, because you will never be able to use it again. So this is where the garbage collector comes in place and free that unused variables and allowed you to not bother at all and focus on the higher level stuff, cool stuff.

In older programming languages, like C, GC was not a thing, and developers have to manually free the unused space, so as you can imagine, this was a huge part in developing any program, because, if you forget to free some memory, you will have memory leaks. So, be thankful for GC.

Now that we understand the power of GC, lets try to understand how they work:

Well, they're multiple algorithms that implement GC, Mark-Sweep-Compact, Evacuation, G1 and Shenandoah. Each one of them do the same thing, collect all the unused variables and free the memory their using. We aren't going to discuss the algorithms itself, just understand the principles that they all share:

  • Check all variables.
  • Free the ones without a reference.
  • Rearrange the heap.
The difference between one another are the way they implement this three points, but what we are going to discuss is Shenandoah algorithm; this is the newer one and it brings a fascinating stuff to the table. 

Shenandoah does all the GC stuff with pauses between 1 and 50 ms, meanwhile the other ones pause the application 1 to 3 sec in average. This is a real step forward the right direction, and we have to understand that GC algorithm are all about trade-offs. 

I'm really curious where are GC going on the future. 




Comentarios

Entradas más populares de este blog

The Secret History of Women in Coding

Rich Hickey on Clojure

Dick Gabriel on Lisp