Learning about Memory Management in Java and Go
This article introduces the study of memory management in Java and Go, using GC to achieve automatic memory management, which helps in gaining a deeper understanding of performance bottlenecks. GC is divided into three types: Serial GC, Parallel GC, and Concurrent GC, each with its own characteristics and applicable scenarios. GC strategies include Copying GC, Mark-sweep GC, and Mark-compact GC, each with its own advantages and disadvantages. Reference counting is one method for determining dead objects, but it has drawbacks such as thread safety issues and the inability to handle cyclic structures. Java memory management technology has evolved over multiple generations, adopting generational collection, which selects different cleanup strategies based on the lifespan of objects. Golang uses the tri-color marking method to track dead objects, using white, gray, and black to represent objects that can be reclaimed, are being examined, and cannot be reclaimed, respectively.
🕒 5 min read