0
author: "Sharva Pathak"
https://www.glean.com/jp/blog/how-we-analyzed-and-fixed-a-golang-memory-leak(www.glean.com)A Go service experienced a gradual, persistent increase in memory usage, strongly indicating a memory leak that needed investigation. Using Go's built-in `pprof` tool, developers analyzed the application's heap profile to identify the source of the problem. The analysis revealed that a large number of goroutines were not being terminated and remained in memory. The root cause was an error handling path that failed to call `Done()` on a `sync.WaitGroup`, which prevented the associated goroutines from ever being garbage collected. By implementing a `defer` statement to ensure `Done()` was called in all scenarios, the leak was successfully patched and memory consumption stabilized.
0 points•by will22•1 hour ago
Comments (0)
No comments yet. Be the first to comment!
Have an account? Log in to join the discussion.