Loading...
Loading...
Browse 4 real-world technical and behavioral interview questions about Memory leaks. Review scenarios, edge cases, and architectural best practices.
A goroutine leak in Go happens when a goroutine blocks forever on a send, receive, network call or abandoned worker path. Find it with goroutine counts and pprof, then add cancellation to every blocking operation. Use this goroutines answer to show the decision, trade-off, and evidence rather than a memorised definition. It also connects channels to the point an interviewer is testing.
Observer decouples a subject from things that react to it, which is right when the subject genuinely should not know its listeners. The costs are a control flow you cannot read from the code, listener lifetimes that leak, and an exception in one observer that silently prevents the rest from running.
Structured concurrency ties a coroutine's lifetime to a CoroutineScope so cancellation propagates automatically, but a leak still happens when a coroutine is launched in a scope that outlives the component that should own it, such as GlobalScope or a manually retained scope nobody cancels. Use this KOTLIN answer to show the decision, trade-off, and evidence rather than a memorised definition.
A closure is a function plus the scope it was created in, held by reference rather than copied. It leaks when something long-lived keeps the function alive, because everything the captured scope can reach stays reachable with it.