Garbage Management: Java vs Go
Content table for blog
- Introduction to blog.
- what is Garbage Collection/Collector?
- How GC operates.
- Java’s GC
- Golang’s GC.
- Links to resources
Welcome to yet another blog on the internet about Golang, but don’t worry I won’t say pick Golang because it has optimised garbage collection, rather let’s understand what this statement means. Since we call ourselves software developers let’s do the DFS about the infamous Garbage Collection in Golang.
What is Garbage Collection/Collector?
Assume you write code; to implement it, a specific procedure is called, and it is given a specific amount of RAM. What happens next? The function or code that has completed its task has reserved memory in RAM until it is deleted, resulting in a memory leak/memory overflow.
But, surely, we can free the memory? Yes, we can, and we can make mistakes and blow things off in the process (“the intern brought down the prod again”). This was an issue with boomers like C and C++, but GenZ Go and evergreen Java made their garbage collector automatic. As a result, users face less of a burden.
This is referred to as Garbage Collector (GC).