As discussed in the Memory object allocation section of Chapter 8, Memory Management in Go, we have a myriad of tools at our disposal to view the current memory statistics for our currently executing program. In this chapter, we will also learn about profiling using the pprof tool. One of the more common Go memory leaks is the unbounded creation of goroutines. This happens frequently when you overload an unbuffered channel or you have an abstraction with a lot of concurrency spawning new goroutines that don't finish. Goroutines have a very small footprint and systems can often spawn a very large number of them, but they eventually have an upper bound that becomes taxing to find when trying to troubleshoot your program in a production environment.
In the following example, we are going to look at an unbuffered channel that has a leaky abstraction...