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.
Comentarios
Publicar un comentario