Skip to content
Preptima

Top 4 Memory leaks Interview Questions

Browse 4 real-world technical and behavioral interview questions about Memory leaks. Review scenarios, edge cases, and architectural best practices.

How do goroutines leak, and how would you find a leak in a running service?

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.

mediumconcept

When would you use the observer pattern, and what goes wrong with it at scale?

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.

mediumconcept

What does structured concurrency actually give you in Kotlin coroutines, and how does a coroutine scope leak happen despite it?

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.

mediumconcept

What is a closure, and how does one end up leaking memory?

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.

mediumconcept