All 56 questions
How does Java garbage collection work, and how do you investigate garbage collection and memory problems?
Asked in 8 of 335 interviews · last asked Oct 30 · Concept · Junior
Show answer
Java garbage collection reclaims heap memory from objects no longer reachable from GC roots, such as live threads and static fields. It can cause pauses and use CPU; behavior depends on the JVM and collector. I examine GC logs, allocation rates, and heap usage, then use heap dumps and profiling to find the cause.
- Frequent collections can indicate heavy allocation; growing heap usage after collection can suggest retained objects.
- Use heap dumps to inspect retained sizes and paths to GC roots.
- Java 9 and later support GC logging with -Xlog:gc*; older versions use different flags.
- Check native memory too: an OutOfMemoryError does not always mean the Java heap is full.
What the interviewer checks: The interviewer checks whether you understand object reachability, GC performance costs, and how to diagnose memory problems using evidence.
Other ways it was asked
- “What is garbage collection, and how can it affect the performance of a Java application?”
- “What is garbage collection in .NET?”
- “Can you explain garbage collection?”
How do unique_ptr, shared_ptr, and weak_ptr differ, and when would you use each?
Asked in 3 of 335 interviews · last asked Oct 4 · Concept · Mid-level
Show answer
std::unique_ptr owns an object alone; use it by default when ownership is not shared. std::shared_ptr shares ownership and deletes the object when the last shared owner releases it. std::weak_ptr observes a shared_ptr-managed object without keeping it alive; use it to break ownership cycles or access an object that may be gone.
- unique_ptr cannot be copied, but moving it transfers ownership.
- shared_ptr can be copied; reference counting adds memory and runtime costs.
- weak_ptr::lock() returns a shared_ptr, or an empty one if the object has expired.
- shared_ptr manages lifetime; it does not make access to the object thread-safe.
What the interviewer checks: The interviewer checks whether you can choose clear ownership rules and avoid leaks or access to destroyed objects.
Other ways it was asked
- “What are the key differences between std::unique_ptr and std::shared_ptr in C++?”
- “What is the difference between std::unique_ptr and std::shared_ptr, and when would you choose one over the other?”
- “Could you expand on how you decide between using unique_ptr, shared_ptr, and weak_ptr in a real system?”
How do C++ smart pointers manage memory, and when is manual memory management still necessary?
Asked in 3 of 335 interviews · last asked Oct 30 · Concept · Junior
Show answer
C++ smart pointers manage memory through ownership and automatic cleanup when their lifetime ends. std::unique_ptr owns an object alone; std::shared_ptr deletes it when the last shared owner releases it. Manual memory management may still be needed inside custom allocators or when integrating legacy APIs, but ownership should use smart pointers where possible.
- Smart pointers use RAII: their destructors release owned resources, including during exception handling.
- std::unique_ptr transfers ownership by moving; std::shared_ptr uses reference counting, which adds overhead.
- std::weak_ptr observes shared objects without owning them and can break shared ownership cycles.
- Custom deleters let smart pointers handle many APIs that require special cleanup functions.
What the interviewer checks: The interviewer checks whether you understand ownership, object lifetime, and when explicit cleanup is still needed.
Other ways it was asked
- “What are smart pointers?”
- “What are smart pointers in C++?”
- “Can you explain what smart pointers are?”
How do you prevent Angular subscription leaks, and when should you use async pipe versus manual unsubscribe?
Asked in 2 of 335 interviews · last asked Sep 16 · Scenario · Mid-level
Other ways it was asked
- “In Angular, how do you manage subscriptions in a component to avoid memory leaks, especially for long-lived streams such as router events or value changes?”
- “How do you prevent memory leaks from RxJS subscriptions in Angular components, and when would you prefer the async pipe versus manual unsubscribe?”
How do strong reference cycles cause Swift memory leaks, and how do you detect and break them?
Asked in 2 of 335 interviews · last asked Aug 17 · Concept · Mid-level
Other ways it was asked
- “In Swift, explain how ARC can still lead to memory leaks via strong reference cycles and how you typically detect and break them in production apps.”
- “How do you break a retain cycle between two classes?”
- “Does an unowned reference help break a retain cycle?”
How do you manage memory in C++?
Asked in 2 of 335 interviews · last asked Oct 14 · Concept · Mid-level
Other ways it was asked
- “How would you manage memory allocation in C?”
How does garbage collection work in Unity?
Asked once · last asked Sep 8 · Concept · Senior
How does garbage collection reclaim unused memory in .NET?
Asked once · last asked Jan 28 · Concept · Mid-level
When does a PHP object's destructor run, and how can you trigger its cleanup?
Asked once · last asked Mar 27 · Concept · Mid-level
Other ways it was asked
- “When is a PHP destructor called, and how does it work?”
- “How can you trigger a PHP object's destructor so that its cleanup logic runs?”
How would you handle a large PHP array that needs to be cleared periodically?
Asked once · last asked Mar 27 · Scenario · Mid-level
How does the .NET disposable pattern work, and when and how should you call Dispose?
Asked once · last asked Apr 2 · Concept · Mid-level
Other ways it was asked
- “What is the disposable pattern in .NET, and how does it work?”
- “When should you use the disposable pattern?”
- “What is the purpose of Dispose in .NET, and does it remove an object from memory?”
What is the difference between a finalizer and Dispose?
Asked once · last asked Apr 2 · Concept · Mid-level
How would you choose a garbage collector implementation for an application?
Asked once · last asked Apr 13 · Scenario · Senior
What memory-management differences between the JVM and iOS should Kotlin Multiplatform developers account for?
Asked once · last asked May 4 · Concept · Senior
In what scenarios would you share functionality in Kotlin Multiplatform versus implement it natively on iOS to avoid memory-management issues related to object lifetimes?
Asked once · last asked May 4 · Scenario · Senior
Does Go use a garbage collector, an interpreter, or both?
Asked once · last asked Jun 9 · Concept · Junior
Other ways it was asked
- “Does Go have a garbage collector?”
In Node.js, what's the practical difference between EventEmitter's .on and .once methods, and how do you prevent listener leaks in long-lived processes?
Asked once · last asked Jul 3 · Tooling · Senior
Can you explicitly trigger garbage collection in Java, and is it guaranteed to run?
Asked once · last asked Jul 16 · Concept · Mid-level
Why can subscribing to an event cause a memory leak in Unity, and how would you detect and fix it?
Asked once · last asked Jul 17 · Scenario · Senior
When would you use weak versus unowned in Swift, and what failure modes should you consider?
Asked once · last asked Jul 20 · Concept · Senior
Other ways it was asked
- “How do you decide between weak and unowned for a reference, for example in delegates, closures, or parent-child relationships, and what failure modes are you guarding against?”
- “Pick one concrete example, such as a delegate, closure, or parent-child relationship, and walk me through when you'd use weak versus unowned there, and why.”
What does managed code mean in the .NET context, and specifically what does the CLR manage?
Asked once · last asked Aug 6 · Concept · Junior
Can value types such as structs and enums cause a retain cycle?
Asked once · last asked Aug 17 · Concept · Senior
Which types support reference counting in Swift?
Asked once · last asked Aug 17 · Concept · Mid-level
Should a Swift delegate reference be weak or strong, and why?
Asked once · last asked Aug 17 · Concept · Mid-level
Other ways it was asked
- “Can you define a delegate variable using a strong reference?”
- “Should a delegate variable be weak or strong, and why?”
What was Java's finalize() method intended for, and how did it work?
Asked once · last asked Sep 4 · Concept · Mid-level
Why does C# provide GC.Collect, and when might you use it?
Asked once · last asked Sep 21 · Concept · Mid-level
What happens internally to the control block of a std::shared_ptr when you copy the shared pointer and when you destroy one copy?
Asked once · last asked Sep 21 · Concept · Mid-level
Other ways it was asked
- “What happens internally to a std::shared_ptr control block when you copy it and when you destroy one copy?”
How does memory management in .NET and C# differ from memory management in C++?
Asked once · last asked Sep 29 · Concept · Senior
How would you use WeakMap or WeakSet to prevent memory leaks when associating metadata with DOM nodes or object keys?
Asked once · last asked Oct 3 · Concept · Senior
In C++, what is the rule of five, and which five special member functions does it refer to?
Asked once · last asked Oct 4 · Concept · Mid-level
How does garbage collection work in V8, including generational, minor, and major collection, and what constitutes a memory leak in JavaScript?
Asked once · last asked Oct 7 · Concept · Senior
Other ways it was asked
- “How does garbage collection work in V8, and what are generational, minor, and major garbage collection and a JavaScript memory leak?”
What is a unique pointer in C++, and how is it used?
Asked once · last asked Oct 9 · Concept · Junior
Other ways it was asked
- “What is a shared pointer in C++, and how is it used?”
How can a memory leak occur when using smart pointers in C++?
Asked once · last asked Oct 9 · Concept · Mid-level
What is the Rule of Three in C++?
Asked once · last asked Oct 9 · Concept · Mid-level
What are the benefits of registering an interface with its implementation and choosing its lifetime in the dependency injection container?
Asked once · last asked Oct 15 · Concept · Mid-level
How can a retain cycle form between class instances in Swift?
Asked once · last asked Oct 28 · Concept · Mid-level
Other ways it was asked
- “How can a retain cycle form between objects in a Swift class?”
Where do retain cycles commonly occur in iOS projects, and how can you avoid them?
Asked once · last asked Oct 28 · Scenario · Senior
How do you adjust JVM memory parameters and choose a garbage collector such as Parallel GC?
Asked once · last asked Oct 28 · Concept · Senior
Can you explain how Go's GC interacts with sync.Pool, and when using sync.Pool can hurt performance or correctness?
Asked once · last asked Oct 30 · Concept · Senior
How do you prevent memory leaks in a long-running embedded system?
Asked once · last asked Oct 30 · Scenario · Senior
Why is garbage collection necessary, and how does the JVM perform garbage collection?
Asked once · last asked Nov 5 · Concept · Mid-level
How do you track and reset pooled objects’ internal state to avoid leaks, like lingering timers, messages, or physics interactions, when an instance is reused?
Asked once · last asked Nov 5 · Scenario · Senior
How would you choose between server GC and workstation GC for a .NET API, and why does the choice matter?
Asked once · last asked Nov 17 · Concept · Senior
Other ways it was asked
- “Is your API using server GC or workstation GC, and why does the choice matter?”
What is the garbage collector in C#?
Asked once · last asked Sep 21 · Concept · Junior
Other ways it was asked
- “Can you explicitly invoke the garbage collector in C#?”
What is a garbage collector, and what is its purpose?
Asked once · last asked Mar 27 · Concept · Junior
When might a garbage collector not be used?
Asked once · last asked Mar 27 · Concept · Junior
What does the JavaScript garbage collector do?
Asked once · last asked Apr 4 · Concept · Junior
What is the difference between a garbage collector and an interpreter?
Asked once · last asked Jun 9 · Concept · Junior
What are some important rules and use cases for destructors in C++?
Asked once · last asked Jul 16 · Concept · Junior
What is memory management in Python?
Asked once · last asked Aug 12 · Concept · Junior
What do semantics and RAII mean in C++?
Asked once · last asked Aug 12 · Concept · Mid-level
Which .NET component determines when objects are released and memory is freed?
Asked once · last asked Sep 4 · Concept · Junior
In C#, does the garbage collector clean heap memory, stack memory, or both?
Asked once · last asked Sep 21 · Concept · Junior
What are the different types of garbage collectors?
Asked once · last asked Oct 16 · Concept · Senior
Other ways it was asked
- “Do you know about the different types of garbage collectors?”
What is meant by retain cycle?
Asked once · last asked Oct 28 · Concept · Mid-level
What are the young and old generations in the Java heap?
Asked once · last asked Nov 10 · Concept · Mid-level
More Operating Systems interview questions
- All Operating Systems interview questions
- Memory Management, Stack and Heap Interview Questions
- Memory Leaks and Performance Troubleshooting Interview Questions
- Large Data Processing and Out-of-memory Interview Questions
How this list is made
Every question here was asked by a real interviewer in a real job interview that a candidate ran MeetAssist in. After the call, the interviewer's questions are pulled from the transcript. Practice sessions, tests, exams and anything that was not a job interview are dropped.
Questions are rewritten so they make sense on their own: names of people, employers and clients are removed, and speech-to-text mistakes are fixed. Small talk, logistics and questions about one candidate's own résumé are left out. Rephrasings of the same question are merged, and the count is the number of different interviews it came up in.
The interviews come from candidates who use MeetAssist, so they lean towards software, data and AI roles: the shares describe these interviews, not every Operating Systems interview. Answers to the most asked questions are written and checked by an editor; a "common mistake" is shown only when reviews of real answers in these interviews show it, with the count.
335 interviews, 268 candidates, Dec 2025 to Nov 2026. Updated every month with new interviews.
Or add the Chrome extension